home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim53os2.zip / vim-5.3 / doc / term.txt < prev    next >
Text File  |  1998-08-30  |  29KB  |  641 lines

  1. *term.txt*      For Vim version 5.3.  Last modification: 1998 Aug 17
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Bram Moolenaar
  5.  
  6.  
  7. Terminal information                    *terminal-info*
  8.  
  9. Vim uses information about the terminal you are using to fill the screen and
  10. recognize what keys you hit.  If this information is not correct the screen
  11. may be messed up or keys may not be recognized.  The actions which have to be
  12. performed on the screen are accomplished by outputting a string of
  13. characters.  Special keys produce a string of characters.  These strings are
  14. stored in the terminal options, see |terminal-options|.
  15.  
  16. 1. Startup            |startup-terminal|
  17. 2. Terminal options        |terminal-options|
  18. 3. Window size            |window-size|
  19. 4. Slow and fast terminals    |slow-fast-terminal|
  20. 5. Using the mouse        |mouse-using|
  21.  
  22. ==============================================================================
  23. 1. Startup                        *startup-terminal*
  24.  
  25. When Vim is started a default terminal type is assumed.  For the Amiga this is
  26. a standard CLI window, for MS-DOS the pc terminal, for Unix an ansi terminal.
  27. A few other terminal types are always available, see below |builtin-terms|.
  28.  
  29. You can give the terminal name with the '-T' Vim argument.  If it is not given
  30. Vim will try to get the name from the TERM environment variable.
  31.  
  32.                             *termcap* *terminfo*
  33. On Unix the terminfo database or termcap file is used.  This is referred to as
  34. "termcap" in all the documentation.  At compile time, when running configure,
  35. the choice whether to use terminfo or termcap is done automatically.  When
  36. running Vim the output of ":version" will show |+terminfo| if terminfo is
  37. used.  Also see |xterm-screens|.
  38.  
  39. On non-Unix systems a termcap is only available if Vim was compiled with
  40. TERMCAP defined.
  41.  
  42.                     *builtin-terms* *builtin_terms*
  43. Which builtin terminals are available depends on a few defines in feature.h,
  44. which needs to be set at compile time:
  45.     define        output of ":version"    terminals builtin    ~
  46. NO_BUILTIN_TCAPS    -builtin_terms        none
  47. SOME_BUILTIN_TCAPS    +builtin_terms        most common ones (default)
  48. ALL_BUILTIN_TCAPS    ++builtin_terms        all available
  49.  
  50. You can see a list of available builtin terminals with ":set term=xxx" (when
  51. not running the GUI).  Also see |+builtin_terms|.
  52.  
  53. If the termcap code is included Vim will try to get the strings for the
  54. terminal you are using from the termcap file and the builtin termcaps.  Both
  55. are always used, if an entry for the terminal you are using is present.  Which
  56. one is used first depends on the 'ttybuiltin' option:
  57.  
  58. 'ttybuiltin' on        1: builtin termcap    2: external termcap
  59. 'ttybuiltin' off    1: external termcap    2: builtin termcap
  60.  
  61. If an option is missing in one of them, it will be obtained from the other
  62. one.  If an option is present in both, the one first encountered is used.
  63.  
  64. Which external termcap file is used varies from system to system and may
  65. depend on the environment variables "TERMCAP" and "TERMPATH".  See "man
  66. tgetent".
  67.  
  68. Settings depending on terminal            *term-dependent-settings*
  69.  
  70. If you want to set options or mappings, depending on the terminal name, you
  71. can do this best in your .vimrc.  Example:
  72.  
  73. >   if &term == "xterm"
  74. >     ... xterm maps and settings ...
  75. >   else if &term =~ "vt10."
  76. >     ... vt100, vt102 maps and settings ...
  77. >   endif
  78.  
  79.                         *raw-terminal-mode*
  80. For normal editing the terminal will be put into "raw" mode.  The strings
  81. defined with 't_ti' and 't_ks' will be sent to the terminal.  Normally this
  82. puts the terminal in a state where the termcap codes are valid and activates
  83. the cursor and function keys.  When Vim exits the terminal will be put back
  84. into the mode it was before Vim started.  The strings defined with 't_te' and
  85. 't_ke' will be sent to the terminal.  On the Amiga with commands that execute
  86. an external command (e.g., "!!") the terminal will be put into Normal mode for
  87. a moment.  This means that you can stop the output to the screen by hitting a
  88. printing key.  Output resumes when you hit <BS>.
  89.  
  90.                             *cs7-problem*
  91. Note: If the terminal settings are changed after running Vim, you might have
  92. an illegal combination of settings.  This has been reported on Solaris 2.5
  93. with "stty cs8 parenb", which is restored as "stty cs7 parenb".  Use
  94. "stty cs8 -parenb -istrip" instead, this is restored correctly.
  95.  
  96. Some termcap entries are wrong in the sense that after sending 't_ks' the
  97. cursor keys send codes different from the codes defined in the termcap.  To
  98. avoid this you can set 't_ks' (and 't_ke') to empty strings.  This must be
  99. done during initialization (see |initialization|), otherwise its too late.
  100.  
  101. Some termcap entries assume that the highest bit is always reset.  For
  102. example: The cursor-up entry for the amiga could be ":ku=\EA:".  But the Amiga
  103. really sends "\233A".  This works fine if the highest bit is reset, e.g., when
  104. using an Amiga over a serial line.  If the cursor keys don't work, try the
  105. entry ":ku=\233A:".
  106.  
  107. Some termcap entries have the entry ":ku=\E[A:".  But the Amiga really sends
  108. "\233A".  On output "\E[" and "\233" are often equivalent, on input they
  109. aren't.  You will have to change the termcap entry, or change the key code with
  110. the :set command to fix this.
  111.  
  112. Many cursor key codes start with an <Esc>.  Vim must find out if this a single
  113. hit of the <Esc> key or the start of a cursor key sequence.  It waits for a
  114. next character to arrive.  If it does not arrive within one second a single
  115. <Esc> is assumed.  On very slow systems this may fail, causing cursor keys not
  116. to work sometimes.  If you discover this problem reset the 'timeout' option.
  117. Vim will wait for the next character to arrive after an <Esc>.  If you want to
  118. enter a single <Esc> you must type it twice.  Resetting the 'esckeys' option
  119. avoids this problems in Insert mode, but you lose the possibility to use
  120. cursor and function keys in Insert mode.
  121.  
  122. On the Amiga the recognition of window resizing is activated only when the
  123. terminal name is "amiga" or "builtin_amiga".
  124.  
  125. Some terminals have confusing codes for the cursor keys.  The televideo 925 is
  126. such a terminal.  It sends a CTRL-H for cursor-left.  This would make it
  127. impossible to distinguish a backspace and cursor-left.  To avoid this problem
  128. CTRL-H is never recognized as cursor-left.
  129.  
  130.                     *vt100-cursor-keys* *xterm-cursor-keys*
  131. Other terminals (e.g., vt100 and xterm) have cursor keys that send <Esc>OA,
  132. <Esc>OB, etc.  Unfortunately these are valid commands in insert mode: Stop
  133. insert, Open a new line above the new one, start inserting 'A', 'B', etc.
  134. Instead of performing these commands Vim will erroneously recognize this typed
  135. key sequence as a cursor key movement.  To avoid this and make Vim do what you
  136. want in either case you could use these settings:
  137.     :set notimeout        " don't timeout on mappings
  138.     :set ttimeout        " do timeout on terminal key codes
  139.     :set timeoutlen=100    " timemout in 100 msec
  140. This requires the key-codes to be send within 100msec in order to recognize
  141. them as a cursor key.  When you type you normally are not that fast, so they
  142. are recognized as individual typed commands, even though Vim receives the same
  143. sequence of bytes.
  144.  
  145.                 *vt100-function-keys* *xterm-function-keys*
  146. An xterm can send function keys F1 to F4 in two modes: vt100 compatible or
  147. not.  Because Vim cannot know what the xterm is sending, both types of keys
  148. are recognized:
  149.             normal        vt100 ~
  150.     <F1>>    t_k1    <Esc>[11~    <Esc>OP
  151.     <F2>    t_k2    <Esc>[12~    <Esc>OQ
  152.     <F3>    t_k3    <Esc>[13~    <Esc>OR
  153.     <F4>    t_k4    <Esc>[14~    <Esc>OS
  154.  
  155.                             *xterm-scroll-region*
  156. The default termcap entry for xterm on sun and other platforms does not
  157. contain the entry for scroll regions.  Add ":cs=\E[%i%d;%dr:" to the xterm
  158. entry in /etc/termcap and everything should work.
  159.  
  160.                             *xterm-end-home-keys*
  161. On some systems (at least on FreeBSD with X386 3.1.2) the codes that the <End>
  162. and <Home> keys send contain a <Nul> character.  To make these keys send the
  163. proper key code, add these lines to your ~/.Xdefaults file:
  164.  
  165. *VT100.Translations:        #override \n\
  166.         <Key>Home: string("0x1b") string("[7~") \n\
  167.         <Key>End: string("0x1b") string("[8~")
  168.  
  169. ==============================================================================
  170. 2. Terminal options                    *terminal-options*
  171.  
  172. The terminal options can be set just like normal options.  But they are not
  173. shown with the ":set all" command.  Instead use ":set termcap".
  174.  
  175. It is always possible to change individual strings by setting the
  176. appropriate option.  For example:
  177. >    :set t_ce=^V^[[K    (CTRL-V, <Esc>, [, K)
  178.  
  179. {Vi: no terminal options.  You have to exit Vi, edit the termcap entry and
  180. try again}
  181.  
  182. The options are listed below.  The associated termcap code is always equal to
  183. the last two characters of the option name.  Two termcap codes are required:
  184. Cursor positioning and clear screen.
  185.  
  186. The options 't_da', 't_db', 't_ms', 't_xs' represent flags in the termcap.
  187. When the termcap flag is present, the option will be set to "y".  But any
  188. non-empty string means that the flag is set.  An empty string means that the
  189. flag is set.  't_CS' works like this too, but it isn't a termcap flag.
  190.  
  191. OUTPUT CODES
  192.     option    meaning    ~
  193.  
  194.     t_AB    set background color (ANSI)            *t_AB* *'t_AB'*
  195.     t_AF    set foreground color (ANSI)            *t_AF* *'t_AF'*
  196.     t_AL    add number of blank lines            *t_AL* *'t_AL'*
  197.     t_al    add new blank line                *t_al* *'t_al'*
  198.     t_bc    backspace character                *t_bc* *'t_bc'*
  199.     t_cd    clear to end of screen                *t_cd* *'t_cd'*
  200.     t_ce    clear to end of line                *t_ce* *'t_ce'*
  201.     t_cl    clear screen (required!)            *t_cl* *'t_cl'*
  202.     t_cm    cursor motion (required!)            *t_cm* *'t_cm'*
  203.     t_Co    number of colors                *t_Co* *'t_Co'*
  204.     t_CS    if non-empty, cursor relative to scroll region    *t_CS* *'t_CS'*
  205.     t_cs    define scrolling region                *t_cs* *'t_cs'*
  206.     t_da    if non-empty, lines from above scroll down    *t_da* *'t_da'*
  207.     t_db    if non-empty, lines from below scroll up    *t_db* *'t_db'*
  208.     t_DL    delete number of lines                *t_DL* *'t_DL'*
  209.     t_dl    delete line                    *t_dl* *'t_dl'*
  210.     t_ke    out of "keypad transmit" mode            *t_ke* *'t_ke'*
  211.     t_ks    put terminal in "keypad transmit" mode        *t_ks* *'t_ks'*
  212.     t_le    move cursor one char left            *t_le* *'t_le'*
  213.     t_mb    blinking mode                    *t_mb* *'t_mb'*
  214.     t_md    bold mode                    *t_md* *'t_md'*
  215.     t_me    Normal mode (undoes t_mr, t_mb and t_md)    *t_me* *'t_me'*
  216.     t_mr    reverse (invert) mode                *t_mr* *'t_mr'*
  217.                                 *t_ms* *'t_ms'*
  218.     t_ms    if non-empty, cursor can be moved in standout/inverse mode
  219.     t_nd    non destructive space character            *t_nd* *'t_nd'*
  220.     t_op    reset to original color pair            *t_op* *'t_op'*
  221.     t_RI    cursor number of chars right            *t_RI* *'t_RI'*
  222.     t_Sb    set background color                *t_Sb* *'t_Sb'*
  223.     t_Sf    set foreground color                *t_Sf* *'t_Sf'*
  224.     t_se    standout end                    *t_se* *'t_se'*
  225.     t_so    standout mode                    *t_so* *'t_so'*
  226.     t_sr    scroll reverse (backward)            *t_sr* *'t_sr'*
  227.     t_te    out of "termcap" mode                *t_te* *'t_te'*
  228.     t_ti    put terminal in "termcap" mode            *t_ti* *'t_ti'*
  229.     t_ue    underline end                    *t_ue* *'t_ue'*
  230.     t_us    underline mode                    *t_us* *'t_us'*
  231.     t_vb    visual bell                    *t_vb* *'t_vb'*
  232.     t_ve    cursor visible                    *t_ve* *'t_ve'*
  233.     t_vi    cursor invisible                *t_vi* *'t_vi'*
  234.     t_vs    cursor very visible                *t_vs* *'t_vs'*
  235.                                 *t_xs* *'t_xs'*
  236.     t_xs    if non-empty, standout not erased by overwriting (hpterm)
  237.     t_ZH    italics mode                    *t_ZH* *'t_ZH'*
  238.     t_ZR    italics end                    *t_ZR* *'t_ZR'*
  239.  
  240. KEY CODES
  241. Note: Use the <> form if possible
  242.  
  243.     option    name        meaning    ~
  244.  
  245.     t_ku    <Up>        arrow up            *t_ku* *'t_ku'*
  246.     t_kd    <Down>        arrow down            *t_kd* *'t_kd'*
  247.     t_kr    <Right>        arrow right            *t_kr* *'t_kr'*
  248.     t_kl    <Left>        arrow left            *t_kl* *'t_kl'*
  249.         <S-Up>        shift arrow up
  250.         <S-Down>    shift arrow down
  251.     t_%i    <S-Right>    shift arrow right        *t_%i* *'t_%i'*
  252.     t_#4    <S-Left>    shift arrow left        *t_#4* *'t_#4'*
  253.     t_k1    <F1>        function key 1            *t_k1* *'t_k1'*
  254.     t_k2    <F2>        function key 2            *t_k2* *'t_k2'*
  255.     t_k3    <F3>        function key 3            *t_k3* *'t_k3'*
  256.     t_k4    <F4>        function key 4            *t_k4* *'t_k4'*
  257.     t_k5    <F5>        function key 5            *t_k5* *'t_k5'*
  258.     t_k6    <F6>        function key 6            *t_k6* *'t_k6'*
  259.     t_k7    <F7>        function key 7            *t_k7* *'t_k7'*
  260.     t_k8    <F8>        function key 8            *t_k8* *'t_k8'*
  261.     t_k9    <F9>        function key 9            *t_k9* *'t_k9'*
  262.     t_k;    <F10>        function key 10            *t_k;* *'t_k;'*
  263.     t_F1    <F11>        function key 11            *t_F1* *'t_F1'*
  264.     t_F2    <F12>        function key 12            *t_F2* *'t_F2'*
  265.         <S-F1)        shifted function key 1
  266.         <S-F2>        shifted function key 2
  267.         <S-F3>        shifted function key 3
  268.         <S-F4>        shifted function key 4
  269.         <S-F5>        shifted function key 5
  270.         <S-F6>        shifted function key 6
  271.         <S-F7>        shifted function key 7
  272.         <S-F8>        shifted function key 8
  273.         <S-F9>        shifted function key 9
  274.         <S-F10>        shifted function key 10
  275.         <S-F11>        shifted function key 11
  276.         <S-F12>        shifted function key 12
  277.     t_%1    <Help>        help key            *t_%1* *'t_%1'*
  278.     t_&8    <Undo>        undo key            *t_&8* *'t_&8'*
  279.     t_kI    <Insert>    insert key            *t_kI* *'t_kI'*
  280.     t_kD    <Delete>    delete key            *t_kD* *'t_kD'*
  281.     t_kb    <BS>        backspace key            *t_kb* *'t_kb'*
  282.     t_kh    <Home>        home key            *t_kh* *'t_kh'*
  283.     t_@7    <End>        end key                *t_@7* *'t_@7'*
  284.     t_kP    <PageUp>    page-up key            *t_kP* *'t_kP'*
  285.     t_kN    <PageDown>    page-down key            *t_kN* *'t_kN'*
  286.     t_K1    <kHome>        keypad home key            *t_K1* *'t_K1'*
  287.     t_K4    <kEnd>        keypad end key            *t_K4* *'t_K4'*
  288.     t_K3    <kPageUp>    keypad page-up key        *t_K3* *'t_K3'*
  289.     t_K5    <kPageDown>    keypad page-down key        *t_K5* *'t_K5'*
  290.  
  291. Note about t_so and t_mr: When the termcap entry "so" is not present the
  292. entry for "mr" is used.  And vice versa.  The same is done for "se" and "me".
  293. If your terminal supports both inversion and standout mode, you can see two
  294. different modes.  If you terminal supports only one of the modes, both will
  295. look the same.
  296.  
  297.                             *termcap-colors*
  298. Note about colors: The 't_Co' option tells Vim the number of colors available.
  299. When it is non-zero, the 't_AB' and 't_AF' options are used to set the color.
  300. If one of these is not available, 't_Sb' and 't_Sf' are used.
  301.  
  302.                             *hpterm*
  303. If inversion or other highlighting does not work correctly, try setting the
  304. 't_xs' option to a non-empty string.  This makes the 't_ce' code be used to
  305. remove highlighting from a line.  This is required for "hpterm".  Setting the
  306. 'weirdinvert' option has the same effect as making 't_xs' non-empty, and vise
  307. versa.
  308.  
  309. Some termcaps do not include an entry for 'cs' (scroll region), although the
  310. terminal does support it.  For example: xterm on a sun.  You can use the
  311. builtin_xterm or define t_cs yourself.  For example:
  312. >    :set t_cs=^V^[[%i%d;%dr
  313.  
  314. Where ^V is CTRL-V and ^[ is <Esc>.
  315.  
  316. Unfortunately it is not possible to deduce from the termcap how cursor
  317. positioning should be done when using a scrolling region: Relative to the
  318. beginning of the screen or relative to the beginning of the scrolling region.
  319. Most terminals use the first method.  A known exception is the MS-DOS console
  320. (pcterm).  The 't_CS' option should be set to any string when cursor
  321. positioning is relative to the start of the scrolling region.  It should be
  322. set to an empty string otherwise.  It is default "yes" when 'term' is
  323. "pcterm".
  324.  
  325. Note for xterm users: The shifted cursor keys normally don't work.  You can
  326.     make them work with the xmodmap command and some mappings in Vim.
  327.  
  328.     Give these commands in the xterm:
  329.         xmodmap -e "keysym Up = Up F13"
  330.         xmodmap -e "keysym Down = Down F16"
  331.         xmodmap -e "keysym Left = Left F18"
  332.         xmodmap -e "keysym Right = Right F19"
  333.  
  334.     And use these mappings in Vim:
  335.         :map <t_F3> <S-Up>
  336.         :map! <t_F3> <S-Up>
  337.         :map <t_F6> <S-Down>
  338.         :map! <t_F6> <S-Down>
  339.         :map <t_F8> <S-Left>
  340.         :map! <t_F8> <S-Left>
  341.         :map <t_F9> <S-Right>
  342.         :map! <t_F9> <S-Right>
  343.  
  344. Instead of, say, <S-Up> you can use any other command that you want to use the
  345. shift-cursor-up key for.  (Note: To help people that have a Sun keyboard with
  346. left side keys F14 is not used because it is confused with the undo key; F15
  347. is not used, because it does a window-to-front; F17 is not used, because it
  348. closes the window.  On other systems you can probably use them)
  349.  
  350. ==============================================================================
  351. 3. Window size                        *window-size*
  352.  
  353. [This is about the size of the whole window Vim is using, not a window that is
  354. created with the :split command]
  355.  
  356. If you are running Vim on an Amiga and the terminal name is "amiga" or
  357. "builtin_amiga", the amiga-specific window resizing will be enabled.  On Unix
  358. systems three methods are tried to get the window size:
  359.  
  360. - an ioctl call (TIOCGSIZE or TIOCGWINSZ, depends on your system)
  361. - the environment variables "LINES" and "COLUMNS"
  362. - from the termcap entries "li" and "co"
  363.  
  364. If everything fails a default size of 24 lines and 80 columns is assumed.  If
  365. a window-resize signal is received the size will be set again.  If the window
  366. size is wrong you can use the 'lines' and 'columns' options to set the
  367. correct values.
  368.  
  369. One command can be used to set the screen size:
  370.  
  371.                             *:mod* *:mode*
  372. :mod[e] [mode]
  373.  
  374. Without argument this only detects the screen size.  With MS-DOS it is
  375. possible to switch screen mode.  [mode] can be one of these values:
  376.     "bw40"        40 columns black&white
  377.     "c40"        40 columns color
  378.     "bw80"        80 columns black&white
  379.     "c80"        80 columns color (most people use this)
  380.     "mono"        80 columns monochrome
  381.     "c4350"        43 or 50 lines EGA/VGA mode
  382.     number        mode number to use, depends on your video card
  383.  
  384. ==============================================================================
  385. 4. Slow and fast terminals            *slow-fast-terminal*
  386.                         *slow-terminal*
  387.  
  388. If you have a fast terminal you may like to set the 'ruler' option.  The
  389. cursor position is shown in the status line.  If you are using horizontal
  390. scrolling ('wrap' option off) consider setting 'sidescroll' to a small
  391. number.
  392.  
  393. If you have a slow terminal you may want to reset the 'showcmd' option.
  394. The command characters will not be shown in the status line.  If the terminal
  395. scrolls very slowly, set the 'scrolljump' to 5 or so.  If the cursor is moved
  396. off the screen (e.g., with "j") Vim will scroll 5 lines at a time.  Another
  397. possibility is to reduce the number of lines that Vim uses with the command
  398. "z<height><CR>".
  399.  
  400. If the characters from the terminal are arriving with more than 1 second
  401. between them you might want to set the 'timeout' and/or 'ttimeout' option.
  402. See the "Options" chapter |options|.
  403.  
  404. If your terminal does not support a scrolling region, but it does support
  405. insert/delete line commands, scrolling with multiple windows may make the
  406. lines jump up and down.  If you don't want this set the 'ttyfast' option.
  407. This will redraw the window instead of scroll it.
  408.  
  409. If your terminal scrolls very slowly, but redrawing is not slow, set the
  410. 'ttyscroll' option to a small number, e.g., 3.  This will make Vim redraw the
  411. screen instead of scrolling, when there are more than 3 lines to be scrolled.
  412.  
  413. If you are using Vim over a slow serial line, you might want to try running
  414. Vim inside the "screen" program.  Screen will optimize the terminal I/O quite
  415. a bit.
  416.  
  417. If you are testing termcap options, but you cannot see what is happening,
  418. you might want to set the 'writedelay' option.  When non-zero, one character
  419. is sent to the terminal at a time (does not work for MS-DOS).  This makes the
  420. screen updating a lot slower, making it possible to see what is happening.
  421.  
  422. ==============================================================================
  423. 5. Using the mouse                    *mouse-using*
  424.  
  425. This section is about using the mouse on a terminal or a terminal window.  How
  426. to use the mouse in a GUI window is explained in |gui-mouse|.
  427.  
  428. Don't forget to enable the mouse with this commands:
  429. >    :set mouse=a
  430. Otherwise Vim won't recognize the mouse in all modes (See 'mouse').
  431.  
  432. Currently the mouse is supported for Unix in an xterm window and for MS-DOS.
  433. Mouse clicks can be used to position the cursor, select an area and paste.
  434. The GUI also has menus.
  435.  
  436. These characters in the 'mouse' option tell in which situations the mouse will
  437. be used by Vim:
  438.         n    Normal mode
  439.         v    Visual mode
  440.         i    Insert mode
  441.         c    Command-line mode
  442.         h    all previous modes when in a help file
  443.         a    all previous modes
  444.         r    for |hit-return| prompt
  445.  
  446. The default for 'mouse' is empty, the mouse is not used.  Normally you would do
  447. >    :set mouse=a
  448. to start using the mouse (this is equivalent to setting 'mouse' to "nvich").
  449. If you only want to use the mouse in a few modes or also want to use it for
  450. the two questions you will have to concatenate the letters for those modes.
  451. For example:
  452. >    :set mouse=nv
  453. Will make the mouse work in Normal mode and Visual mode.
  454. >    :set mouse=h
  455. Will make the mouse work in help files only (so you can use "g<LeftMouse>" to
  456. jump to tags).
  457.  
  458. Whether the selection that is started with the mouse is in Visual mode or
  459. Select mode depends on whethere "mouse" in included in the 'selectmode'
  460. option.
  461.  
  462. In an xterm, with the currently active mode included in the 'mouse' option,
  463. normal mouse clicks are used by Vim, mouse clicks with the shift or ctrl key
  464. pressed go the the xterm.  With the currently active mode not included in
  465. 'mouse' all mouse clicks go to the xterm.
  466.  
  467. Here is how you copy and paste a piece of text:
  468.  
  469. Copy/paste with the mouse and Visual mode ('mouse' option must be set, see
  470. above):
  471. 1. Press left mouse button on first letter of text, move mouse pointer to last
  472.    letter of the text and release the button.  This will start Visual mode and
  473.    highlight the selected area.
  474. 2. Press "y" to yank the Visual text in the unnamed register.
  475. 3. Click the left mouse button at the insert position.
  476. 4. Click the middle mouse button.
  477.  
  478. Shortcut: If the insert position is on the screen at the same time as the
  479. Visual text, you can do 2, 3 and 4 all in one: Click the middle mouse button
  480. at the insert position.
  481.  
  482.                             *xterm-copy-paste*
  483. NOTE: In some (older) xterms, it's not possible to move the cursor past column
  484. 95.  This is an xterm problem, not Vim's.
  485.  
  486. Copy/paste in xterm with (current mode NOT included in 'mouse'):
  487. 1. Press left mouse button on first letter of text, move mouse pointer to last
  488.    letter of the text and release the button.
  489. 2. Use normal Vim commands to put the cursor at the insert position.
  490. 3. Press "a" to start Insert mode.
  491. 4. Click the middle mouse button.
  492. 5. Press ESC to end Insert mode.
  493. (The same can be done with anything in 'mouse' if you keep the shift key
  494. pressed while using the mouse)
  495.  
  496. Note: if you lose the 8th bit when pasting (special characters are translated
  497. into other characters), you may have to do "stty cs8 -istrip -parenb" in your
  498. shell before starting Vim.
  499.  
  500. Thus in an xterm the shift and ctrl keys cannot be used with the mouse.  To
  501. make it possible to do the mouse commands that require the ctrl modifier, the
  502. "g" key can be typed before using the mouse:
  503.     "g<LeftMouse>"    is "<C-LeftMouse>    (jump to tag under mouse click)
  504.     "g<RightMouse>" is "<C-RightMouse>    ("CTRL-T")
  505.  
  506. A short overview of what the mouse buttons do, when 'mousemodel' is "extend":
  507.  
  508. Normal Mode:
  509. event          position       selection      change  action    ~
  510.            cursor              window        ~
  511. <LeftMouse>     yes         end        yes
  512. <C-LeftMouse>   yes         end        yes       "CTRL-]" (2)
  513. <S-LeftMouse>   yes      no change        yes       "*" (2)    *<S-LeftMouse>*
  514. <LeftDrag>      yes    start or extend (1) no              *<LeftDrag>*
  515. <LeftRelease>   yes    start or extend (1) no
  516. <MiddleMouse>   yes      if not active     no       put
  517. <MiddleMouse>   yes      if active        no       yank and put
  518. <RightMouse>    yes    start or extend     yes
  519. <S-RightMouse>  yes       no change        yes       "#" (2)    *<S-RightMouse>*
  520. <C-RightMouse>  no       no change        no       "CTRL-T"
  521. <RightDrag>     yes        extend        no              *<RightDrag>*
  522. <RightRelease>  yes        extend        no              *<RightRelease>*
  523.  
  524. Insert or Replace Mode:
  525. event          position       selection      change  action    ~
  526.            cursor              window        ~
  527. <LeftMouse>     yes     (cannot be active)  yes
  528. <C-LeftMouse>   yes     (cannot be active)  yes       "CTRL-O^]" (2)
  529. <S-LeftMouse>   yes     (cannot be active)  yes       "CTRL-O*" (2)
  530. <LeftDrag>      yes     start or extend (1) no       like CTRL-O (1)
  531. <LeftRelease>   yes     start or extend (1) no       like CTRL-O (1)
  532. <MiddleMouse>   no      (cannot be active)  no       put register
  533. <RightMouse>    yes     start or extend        yes       like CTRL-O
  534. <S-RightMouse>  yes     (cannot be active)  yes       "CTRL-O#" (2)
  535. <C-RightMouse>  no    (cannot be active)  no       "CTRL-O CTRL-T"
  536.  
  537. In a help window:
  538. event          position       selection      change  action    ~
  539.            cursor              window        ~
  540. <2-LeftMouse>   yes     (cannot be active)  no       "^]" (jump to help tag)
  541.  
  542. When 'mousemodel' is "popup", these are different:
  543.  
  544. Normal Mode:
  545. event          position       selection      change  action    ~
  546.            cursor              window        ~
  547. <S-LeftMouse>    yes    start or extend (1) no
  548. <RightMouse>    no    popup menu        no
  549.  
  550. Insert or Replace Mode:
  551. event          position       selection      change  action    ~
  552.            cursor              window        ~
  553. <S-LeftMouse>   yes     start or extend (1) no       like CTRL-O (1)
  554. <RightMouse>    no    popup menu        no
  555.  
  556. (1) only if mouse pointer moved since press
  557. (2) only if click is in same buffer
  558.  
  559. Clicking the left mouse button causes the cursor to be positioned.  If the
  560. click is in another window that window is made the active window.  When
  561. editing the command-line the cursor can only be positioned on the
  562. command-line.  When in Insert mode Vim remains in Insert mode.  If 'scrolloff'
  563. is set, and the cursor is positioned within 'scrolloff' lines from the window
  564. border, the text is scrolled.
  565.  
  566. A seleciton can be started by pressing the left mouse button on the first
  567. character, moving the mouse to the last character, then releasing the mouse
  568. button.  You will not always see the selection until you release the button,
  569. only in some versions (GUI, MS-DOS, WIN32) will the dragging be shown
  570. immediately.  Note that you can make the text scroll by moving the mouse at
  571. least one character in the first/last line in the window when 'scrolloff' is
  572. non-zero.
  573.  
  574. In Normal, Visual and Select mode clicking the right mouse button causes the
  575. Visual area to be extended.  When 'mousemodel' is "popup", the left button has
  576. to be used while keeping the shift key pressed.  When clicking in a window
  577. which is editing another buffer, the Visual or Select mode is stopped.
  578.  
  579. Double, triple and quadruple clicks are supported when the GUI is active,
  580. for MS-DOS and Win32, and for an xterm (if the gettimeofday() function is
  581. available).  Double clicking may be done to make the selection word-wise,
  582. triple clicking makes it line-wise, and quadruple clicking makes it
  583. rectangular block-wise.  For MS-DOS and xterm the time for double clicking can
  584. be set with the 'mousetime' option.  For the other systems this time is
  585. defined outside of Vim.
  586.  
  587. In Insert mode, when a selected is started, Vim goes into Normal mode
  588. temporarily.  When Visual or Select mode ends, it returns to Insert mode.
  589. This is like using CTRL-O in Insert mode.  Select mode is used when the
  590. 'selectmode' option contains "mouse".
  591.  
  592.                             *drag-status-line*
  593. When working with several windows, the size of the windows can be changed by
  594. dragging the status line with the mouse.  Point the mouse at a status line,
  595. press the left button, move the mouse to the new position of the status line,
  596. release the button.  Just clicking the mouse in a status line makes that window
  597. the current window, without moving the cursor.  If by selecting a window it
  598. will change position or size, the dragging of the status line will look
  599. confusing, but it will work (just try it).
  600.  
  601. Mouse clicks can be mapped.  The codes for mouse clicks are:
  602.      code        mouse button          normal action    ~
  603.  <LeftMouse>     left pressed            set cursor position
  604.  <LeftDrag>     left moved while pressed   extend selection
  605.  <LeftRelease>     left released            set selection end
  606.  <MiddleMouse>     middle pressed            paste text at cursor position
  607.  <MiddleDrag>     middle moved while pressed -
  608.  <MiddleRelease> middle released        -
  609.  <RightMouse>     right pressed            extend selection
  610.  <RightDrag>     right moved while pressed  extend selection
  611.  <RightRelease>  right released            set selection end
  612.  
  613. Examples:
  614. >    :noremap <MiddleMouse> <LeftMouse><MiddleMouse>
  615. Paste at the position of the middle mouse button click (otherwise the paste
  616. would be done at the cursor position).
  617.  
  618. >    :noremap <LeftRelease> <LeftRelease>y
  619. Immediately yank the selection, when using Visual mode.
  620.  
  621. Note the use of ":noremap" instead of "map" to avoid a recursive mapping.
  622.  
  623.                         *mouse-swap-buttons*
  624. To swap the meaning of the left and right mouse buttons:
  625. >    :noremap    <LeftMouse>    <RightMouse>
  626. >    :noremap    <LeftDrag>    <RightDrag>
  627. >    :noremap    <LeftRelease>    <RightRelease>
  628. >    :noremap    <RightMouse>    <LeftMouse>
  629. >    :noremap    <RightDrag>    <LeftDrag>
  630. >    :noremap    <RightRelease>    <LeftRelease>
  631. >    :noremap    g<LeftMouse>    <C-RightMouse>
  632. >    :noremap    g<RightMouse>    <C-LeftMouse>
  633. >    :noremap!    <LeftMouse>    <RightMouse>
  634. >    :noremap!    <LeftDrag>    <RightDrag>
  635. >    :noremap!    <LeftRelease>    <RightRelease>
  636. >    :noremap!    <RightMouse>    <LeftMouse>
  637. >    :noremap!    <RightDrag>    <LeftDrag>
  638. >    :noremap!    <RightRelease>    <LeftRelease>
  639.  
  640.  vim:tw=78:ts=8:sw=8:
  641.