term.txt 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  1. *term.txt* For Vim version 9.0. Last change: 2022 Dec 01
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Terminal information *terminal-info*
  4. Vim uses information about the terminal you are using to fill the screen and
  5. recognize what keys you hit. If this information is not correct, the screen
  6. may be messed up or keys may not be recognized. The actions which have to be
  7. performed on the screen are accomplished by outputting a string of
  8. characters. Special keys produce a string of characters. These strings are
  9. stored in the terminal options, see |terminal-options|.
  10. NOTE: Most of this is not used when running the |GUI|.
  11. 1. Startup |startup-terminal|
  12. 2. Terminal options |terminal-options|
  13. 3. Window size |window-size|
  14. 4. Slow and fast terminals |slow-fast-terminal|
  15. 5. Using the mouse |mouse-using|
  16. ==============================================================================
  17. 1. Startup *startup-terminal*
  18. When Vim is started a default terminal type is assumed. For the Amiga this is
  19. a standard CLI window, for MS-Windows the pc terminal, for Unix an ansi
  20. terminal. A few other terminal types are always available, see below
  21. |builtin-terms|.
  22. You can give the terminal name with the '-T' Vim argument. If it is not given
  23. Vim will try to get the name from the TERM environment variable.
  24. *termcap* *terminfo* *E557* *E558* *E559*
  25. On Unix the terminfo database or termcap file is used. This is referred to as
  26. "termcap" in all the documentation. At compile time, when running configure,
  27. the choice whether to use terminfo or termcap is done automatically. When
  28. running Vim the output of ":version" will show |+terminfo| if terminfo is
  29. used. Also see |xterm-screens|.
  30. On non-Unix systems a termcap is only available if Vim was compiled with
  31. TERMCAP defined.
  32. *builtin-terms* *builtin_terms*
  33. A number of builtin terminals are available. Since patch 9.0.0280 there is no
  34. difference between Vim versions. You can see a list of available builtin
  35. terminals in the error message you get for `:set term=xxx` (when not running
  36. the GUI). Also see |++builtin_terms|.
  37. If the termcap code is included Vim will try to get the strings for the
  38. terminal you are using from the termcap file and the builtin termcaps. Both
  39. are always used, if an entry for the terminal you are using is present. Which
  40. one is used first depends on the 'ttybuiltin' option:
  41. 'ttybuiltin' on 1: builtin termcap 2: external termcap
  42. 'ttybuiltin' off 1: external termcap 2: builtin termcap
  43. If an option is missing in one of them, it will be obtained from the other
  44. one. If an option is present in both, the one first encountered is used.
  45. Which external termcap file is used varies from system to system and may
  46. depend on the environment variables "TERMCAP" and "TERMPATH". See "man
  47. tgetent".
  48. Settings depending on terminal *term-dependent-settings*
  49. If you want to set options or mappings, depending on the terminal name, you
  50. can do this best in your .vimrc. Example: >
  51. if &term == "xterm"
  52. ... xterm maps and settings ...
  53. elseif &term =~ "vt10."
  54. ... vt100, vt102 maps and settings ...
  55. endif
  56. <
  57. *raw-terminal-mode*
  58. For normal editing the terminal will be put into "raw" mode. The strings
  59. defined with 't_ti', 't_TI' and 't_ks' will be sent to the terminal. Normally
  60. this puts the terminal in a state where the termcap codes are valid and
  61. activates the cursor and function keys.
  62. When Vim exits the terminal will be put back into the mode it was before Vim
  63. started. The strings defined with 't_te', 't_TE' and 't_ke' will be sent to
  64. the terminal. On the Amiga, with commands that execute an external command
  65. (e.g., "!!"), the terminal will be put into Normal mode for a moment. This
  66. means that you can stop the output to the screen by hitting a printing key.
  67. Output resumes when you hit <BS>.
  68. Note: When 't_ti' is not empty, Vim assumes that it causes switching to the
  69. alternate screen. This may slightly change what happens when executing a
  70. shell command or exiting Vim. To avoid this use 't_TI' and 't_TE'.
  71. Vim will try to detect what keyboard protocol the terminal is using with the
  72. 't_RK' termcap entry. This is sent after 't_TI', but only when there is no
  73. work to do (no typeahead and no pending commands). That is to avoid the
  74. response to end up in a shell command or arrive after Vim exits.
  75. *xterm-bracketed-paste*
  76. When the 't_BE' option is set then 't_BE' will be sent to the
  77. terminal when entering "raw" mode and 't_BD' when leaving "raw" mode. The
  78. terminal is then expected to put 't_PS' before pasted text and 't_PE' after
  79. pasted text. This way Vim can separate text that is pasted from characters
  80. that are typed. The pasted text is handled like when the middle mouse button
  81. is used, it is inserted literally and not interpreted as commands.
  82. When the cursor is in the first column, the pasted text will be inserted
  83. before it. Otherwise the pasted text is appended after the cursor position.
  84. This means one cannot paste after the first column. Unfortunately Vim does
  85. not have a way to tell where the mouse pointer was.
  86. Note that in some situations Vim will not recognize the bracketed paste and
  87. you will get the raw text. In other situations Vim will only get the first
  88. pasted character and drop the rest, e.g. when using the "r" command. If you
  89. have a problem with this, disable bracketed paste by putting this in your
  90. .vimrc: >
  91. set t_BE=
  92. If this is done while Vim is running the 't_BD' will be sent to the terminal
  93. to disable bracketed paste.
  94. If your terminal supports bracketed paste, but the options are not set
  95. automatically, you can try using something like this: >
  96. if &term =~ "screen"
  97. let &t_BE = "\e[?2004h"
  98. let &t_BD = "\e[?2004l"
  99. exec "set t_PS=\e[200~"
  100. exec "set t_PE=\e[201~"
  101. endif
  102. <
  103. *tmux-integration*
  104. If you experience issues when running Vim inside tmux, here are a few hints.
  105. You can comment-out parts if something doesn't work (it may depend on the
  106. terminal that tmux is running in): >
  107. if !has('gui_running') && &term =~ '^\%(screen\|tmux\)'
  108. " Better mouse support, see :help 'ttymouse'
  109. set ttymouse=sgr
  110. " Enable true colors, see :help xterm-true-color
  111. let &termguicolors = v:true
  112. let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  113. let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
  114. " Enable bracketed paste mode, see :help xterm-bracketed-paste
  115. let &t_BE = "\<Esc>[?2004h"
  116. let &t_BD = "\<Esc>[?2004l"
  117. let &t_PS = "\<Esc>[200~"
  118. let &t_PE = "\<Esc>[201~"
  119. " Enable focus event tracking, see :help xterm-focus-event
  120. let &t_fe = "\<Esc>[?1004h"
  121. let &t_fd = "\<Esc>[?1004l"
  122. execute "set <FocusGained>=\<Esc>[I"
  123. execute "set <FocusLost>=\<Esc>[O"
  124. " Enable modified arrow keys, see :help arrow_modifiers
  125. execute "silent! set <xUp>=\<Esc>[@;*A"
  126. execute "silent! set <xDown>=\<Esc>[@;*B"
  127. execute "silent! set <xRight>=\<Esc>[@;*C"
  128. execute "silent! set <xLeft>=\<Esc>[@;*D"
  129. endif
  130. <
  131. *cs7-problem*
  132. Note: If the terminal settings are changed after running Vim, you might have
  133. an illegal combination of settings. This has been reported on Solaris 2.5
  134. with "stty cs8 parenb", which is restored as "stty cs7 parenb". Use
  135. "stty cs8 -parenb -istrip" instead, this is restored correctly.
  136. Some termcap entries are wrong in the sense that after sending 't_ks' the
  137. cursor keys send codes different from the codes defined in the termcap. To
  138. avoid this you can set 't_ks' (and 't_ke') to empty strings. This must be
  139. done during initialization (see |initialization|), otherwise it's too late.
  140. Some termcap entries assume that the highest bit is always reset. For
  141. example: The cursor-up entry for the Amiga could be ":ku=\E[A:". But the
  142. Amiga really sends "\233A". This works fine if the highest bit is reset,
  143. e.g., when using an Amiga over a serial line. If the cursor keys don't work,
  144. try the entry ":ku=\233A:".
  145. Some termcap entries have the entry ":ku=\E[A:". But the Amiga really sends
  146. "\233A". On output "\E[" and "\233" are often equivalent, on input they
  147. aren't. You will have to change the termcap entry, or change the key code with
  148. the :set command to fix this.
  149. Many cursor key codes start with an <Esc>. Vim must find out if this is a
  150. single hit of the <Esc> key or the start of a cursor key sequence. It waits
  151. for a next character to arrive. If it does not arrive within one second a
  152. single <Esc> is assumed. On very slow systems this may fail, causing cursor
  153. keys not to work sometimes. If you discover this problem reset the 'timeout'
  154. option. Vim will wait for the next character to arrive after an <Esc>. If
  155. you want to enter a single <Esc> you must type it twice. Resetting the
  156. 'esckeys' option avoids this problem in Insert mode, but you lose the
  157. possibility to use cursor and function keys in Insert mode.
  158. On the Amiga the recognition of window resizing is activated only when the
  159. terminal name is "amiga" or "builtin_amiga".
  160. Some terminals have confusing codes for the cursor keys. The televideo 925 is
  161. such a terminal. It sends a CTRL-H for cursor-left. This would make it
  162. impossible to distinguish a backspace and cursor-left. To avoid this problem
  163. CTRL-H is never recognized as cursor-left.
  164. *vt100-cursor-keys* *xterm-cursor-keys*
  165. Other terminals (e.g., vt100 and xterm) have cursor keys that send <Esc>OA,
  166. <Esc>OB, etc. Unfortunately these are valid commands in insert mode: Stop
  167. insert, Open a new line above the new one, start inserting 'A', 'B', etc.
  168. Instead of performing these commands Vim will erroneously recognize this typed
  169. key sequence as a cursor key movement. To avoid this and make Vim do what you
  170. want in either case you could use these settings: >
  171. :set notimeout " don't timeout on mappings
  172. :set ttimeout " do timeout on terminal key codes
  173. :set timeoutlen=100 " timeout after 100 msec
  174. This requires the key-codes to be sent within 100 msec in order to recognize
  175. them as a cursor key. When you type you normally are not that fast, so they
  176. are recognized as individual typed commands, even though Vim receives the same
  177. sequence of bytes.
  178. *vt100-function-keys* *xterm-function-keys*
  179. An xterm can send function keys F1 to F4 in two modes: vt100 compatible or
  180. not. Because Vim may not know what the xterm is sending, both types of keys
  181. are recognized. The same happens for the <Home> and <End> keys.
  182. normal vt100 ~
  183. <F1> t_k1 <Esc>[11~ <xF1> <Esc>OP *<xF1>-xterm*
  184. <F2> t_k2 <Esc>[12~ <xF2> <Esc>OQ *<xF2>-xterm*
  185. <F3> t_k3 <Esc>[13~ <xF3> <Esc>OR *<xF3>-xterm*
  186. <F4> t_k4 <Esc>[14~ <xF4> <Esc>OS *<xF4>-xterm*
  187. <Home> t_kh <Esc>[7~ <xHome> <Esc>OH *<xHome>-xterm*
  188. <End> t_@7 <Esc>[4~ <xEnd> <Esc>OF *<xEnd>-xterm*
  189. When Vim starts, <xF1> is mapped to <F1>, <xF2> to <F2> etc. This means that
  190. by default both codes do the same thing. If you make a mapping for <xF2>,
  191. because your terminal does have two keys, the default mapping is overwritten,
  192. thus you can use the <F2> and <xF2> keys for something different.
  193. *xterm-shifted-keys*
  194. Newer versions of xterm support shifted function keys and special keys. Vim
  195. recognizes most of them. Use ":set termcap" to check which are supported and
  196. what the codes are. Mostly these are not in a termcap, they are only
  197. supported by the builtin_xterm termcap.
  198. *xterm-modifier-keys*
  199. Newer versions of xterm support Alt and Ctrl for most function keys. To avoid
  200. having to add all combinations of Alt, Ctrl and Shift for every key a special
  201. sequence is recognized at the end of a termcap entry: ";*X". The "X" can be
  202. any character, often '~' is used. The ";*" stands for an optional modifier
  203. argument. ";2" is Shift, ";3" is Alt, ";5" is Ctrl and ";9" is Meta (when
  204. it's different from Alt). They can be combined. Examples: >
  205. :set <F8>=^[[19;*~
  206. :set <Home>=^[[1;*H
  207. Another speciality about these codes is that they are not overwritten by
  208. another code. That is to avoid that the codes obtained from xterm directly
  209. |t_RV| overwrite them.
  210. Another special value is a termcap entry ending in "@;*X". This is for cursor
  211. keys, which either use "CSI X" or "CSI 1 ; modifier X". Thus the "@"
  212. stands for either "1" if a modifier follows, or nothing.
  213. *arrow_modifiers*
  214. Several terminal emulators (alacritty, gnome, konsole, etc.) send special
  215. codes for keys with modifiers, but these do not have an entry in the
  216. termcap/terminfo database. You can make them work by adding a few lines in
  217. your vimrc. For example, to make the Control modifier work with arrow keys
  218. for the gnome terminal: >
  219. if &term =~ 'gnome'
  220. execute "set <xUp>=\<Esc>[@;*A"
  221. execute "set <xDown>=\<Esc>[@;*B"
  222. execute "set <xRight>=\<Esc>[@;*C"
  223. execute "set <xLeft>=\<Esc>[@;*D"
  224. endif
  225. < *xterm-scroll-region*
  226. The default termcap entry for xterm on Sun and other platforms does not
  227. contain the entry for scroll regions. Add ":cs=\E[%i%d;%dr:" to the xterm
  228. entry in /etc/termcap and everything should work.
  229. *xterm-end-home-keys*
  230. On some systems (at least on FreeBSD with XFree86 3.1.2) the codes that the
  231. <End> and <Home> keys send contain a <Nul> character. To make these keys send
  232. the proper key code, add these lines to your ~/.Xdefaults file:
  233. *VT100.Translations: #override \n\
  234. <Key>Home: string("0x1b") string("[7~") \n\
  235. <Key>End: string("0x1b") string("[8~")
  236. *xterm-8bit* *xterm-8-bit*
  237. Xterm can be run in a mode where it uses 8-bit escape sequences. The CSI code
  238. is used instead of <Esc>[. The advantage is that an <Esc> can quickly be
  239. recognized in Insert mode, because it can't be confused with the start of a
  240. special key.
  241. For the builtin termcap entries, Vim checks if the 'term' option contains
  242. "8bit" anywhere. It then uses 8-bit characters for the termcap entries, the
  243. mouse and a few other things. You would normally set $TERM in your shell to
  244. "xterm-8bit" and Vim picks this up and adjusts to the 8-bit setting
  245. automatically.
  246. When Vim receives a response to the |t_RV| (request version) sequence and it
  247. starts with CSI, it assumes that the terminal is in 8-bit mode and will
  248. convert all key sequences to their 8-bit variants.
  249. *xterm-kitty* *kitty-terminal*
  250. The Kitty terminal is a special case. Mainly because it works different from
  251. most other terminals, but also because, instead of trying the fit in and make
  252. it behave like other terminals by default, it dictates how applications need
  253. to work when using Kitty. This makes it very difficult for Vim to work in a
  254. Kitty terminal. Some exceptions have been hard coded, but it is not at all
  255. nice to have to make exceptions for one specific terminal.
  256. One of the problems is that the value for $TERM is set to "xterm-kitty". For
  257. Vim this is an indication that the terminal is xterm-compatible and the
  258. builtin xterm termcap entries should be used. Many other terminals depend on
  259. this. However, Kitty is not fully xterm compatible. The author suggested to
  260. ignore the "xterm-" prefix and use the terminfo entry anyway, so that is what
  261. happens now, the builtin xterm termcap entries are not used. However, the
  262. t_RV is set, otherwise other things would not work, such as automatically
  263. setting 'ttymouse' to "sgr".
  264. It is not clear why kitty sets $TERM to "xterm-kitty", the terminal isn't
  265. really xterm compatible. "kitty" would be more appropriate, but a terminfo
  266. entry with that name is not widespread.
  267. Note that using the kitty keyboard protocol is a separate feature, see
  268. |kitty-keyboard-protocol|.
  269. ==============================================================================
  270. 2. Terminal options *terminal-options* *termcap-options* *E436*
  271. The terminal options can be set just like normal options. But they are not
  272. shown with the ":set all" command. Instead use ":set termcap".
  273. It is always possible to change individual strings by setting the
  274. appropriate option. For example: >
  275. :set t_ce=^V^[[K (CTRL-V, <Esc>, [, K)
  276. The options are listed below. The associated termcap code is always equal to
  277. the last two characters of the option name. Only one termcap code is
  278. required: Cursor motion, 't_cm'.
  279. The options 't_da', 't_db', 't_ms', 't_xs', 't_xn' represent flags in the
  280. termcap. When the termcap flag is present, the option will be set to "y".
  281. But any non-empty string means that the flag is set. An empty string means
  282. that the flag is not set. 't_CS' works like this too, but it isn't a termcap
  283. flag.
  284. OUTPUT CODES *terminal-output-codes*
  285. option meaning ~
  286. t_AB set background color (ANSI) *t_AB* *'t_AB'*
  287. t_AF set foreground color (ANSI) *t_AF* *'t_AF'*
  288. t_AL add number of blank lines *t_AL* *'t_AL'*
  289. t_al add new blank line *t_al* *'t_al'*
  290. t_bc backspace character *t_bc* *'t_bc'*
  291. t_cd clear to end of screen *t_cd* *'t_cd'*
  292. t_ce clear to end of line *t_ce* *'t_ce'*
  293. t_cl clear screen *t_cl* *'t_cl'*
  294. t_cm cursor motion (required!) *E437* *t_cm* *'t_cm'*
  295. t_Co number of colors *t_Co* *'t_Co'*
  296. t_CS if non-empty, cursor relative to scroll region *t_CS* *'t_CS'*
  297. t_cs define scrolling region *t_cs* *'t_cs'*
  298. t_CV define vertical scrolling region *t_CV* *'t_CV'*
  299. t_da if non-empty, lines from above scroll down *t_da* *'t_da'*
  300. t_db if non-empty, lines from below scroll up *t_db* *'t_db'*
  301. t_DL delete number of lines *t_DL* *'t_DL'*
  302. t_dl delete line *t_dl* *'t_dl'*
  303. t_fs set window title end (from status line) *t_fs* *'t_fs'*
  304. t_ke exit "keypad transmit" mode *t_ke* *'t_ke'*
  305. t_ks start "keypad transmit" mode *t_ks* *'t_ks'*
  306. t_le move cursor one char left *t_le* *'t_le'*
  307. t_mb blinking mode *t_mb* *'t_mb'*
  308. t_md bold mode *t_md* *'t_md'*
  309. t_me Normal mode (undoes t_mr, t_mb, t_md and color) *t_me* *'t_me'*
  310. t_mr reverse (invert) mode *t_mr* *'t_mr'*
  311. *t_ms* *'t_ms'*
  312. t_ms if non-empty, cursor can be moved in standout/inverse mode
  313. t_nd non destructive space character *t_nd* *'t_nd'*
  314. t_op reset to original color pair *t_op* *'t_op'*
  315. t_RI cursor number of chars right *t_RI* *'t_RI'*
  316. t_Sb set background color *t_Sb* *'t_Sb'*
  317. t_Sf set foreground color *t_Sf* *'t_Sf'*
  318. t_se standout end *t_se* *'t_se'*
  319. t_so standout mode *t_so* *'t_so'*
  320. t_sr scroll reverse (backward) *t_sr* *'t_sr'*
  321. t_te end of "termcap" mode *t_te* *'t_te'*
  322. t_ti put terminal into "termcap" mode *t_ti* *'t_ti'*
  323. t_ts set window title start (to status line) *t_ts* *'t_ts'*
  324. t_ue underline end *t_ue* *'t_ue'*
  325. t_us underline mode *t_us* *'t_us'*
  326. t_ut clearing uses the current background color *t_ut* *'t_ut'*
  327. t_vb visual bell *t_vb* *'t_vb'*
  328. t_ve cursor visible *t_ve* *'t_ve'*
  329. t_vi cursor invisible *t_vi* *'t_vi'*
  330. t_vs cursor very visible (blink) *t_vs* *'t_vs'*
  331. *t_xs* *'t_xs'*
  332. t_xs if non-empty, standout not erased by overwriting (hpterm)
  333. *t_xn* *'t_xn'*
  334. t_xn if non-empty, writing a character at the last screen cell
  335. does not cause scrolling
  336. t_ZH italics mode *t_ZH* *'t_ZH'*
  337. t_ZR italics end *t_ZR* *'t_ZR'*
  338. Added by Vim (there are no standard codes for these):
  339. t_AU set underline color (ANSI) *t_AU* *'t_AU'*
  340. t_Ce undercurl and underline end *t_Ce* *'t_Ce'*
  341. t_Cs undercurl (curly underline) mode *t_Cs* *'t_Cs'*
  342. t_Us double underline mode *t_Us* *'t_Us'*
  343. t_ds dotted underline mode *t_ds* *'t_ds'*
  344. t_Ds dashed underline mode *t_Ds* *'t_Ds'*
  345. t_Te strikethrough end *t_Te* *'t_Te'*
  346. t_Ts strikethrough mode *t_Ts* *'t_Ts'*
  347. t_IS set icon text start *t_IS* *'t_IS'*
  348. t_IE set icon text end *t_IE* *'t_IE'*
  349. t_WP set window position (Y, X) in pixels *t_WP* *'t_WP'*
  350. t_GP get window position (Y, X) in pixels *t_GP* *'t_GP'*
  351. t_WS set window size (height, width in cells) *t_WS* *'t_WS'*
  352. t_VS cursor normally visible (no blink) *t_VS* *'t_VS'*
  353. t_SI start insert mode (bar cursor shape) *t_SI* *'t_SI'*
  354. t_SR start replace mode (underline cursor shape) *t_SR* *'t_SR'*
  355. t_EI end insert or replace mode (block cursor shape) *t_EI* *'t_EI'*
  356. |termcap-cursor-shape|
  357. t_RV request terminal version string (works for *t_RV* *'t_RV'*
  358. xterm and other terminal emulators) The
  359. response is stored in |v:termresponse| |xterm-8bit|
  360. |'ttymouse'| |xterm-codes|
  361. t_RK request terminal keyboard protocol state; *t_RK* *'t_RK'*
  362. sent after |t_TI|
  363. t_u7 request cursor position (for xterm) *t_u7* *'t_u7'*
  364. see |'ambiwidth'|
  365. The response is stored in |v:termu7resp|
  366. t_RF request terminal foreground color *t_RF* *'t_RF'*
  367. The response is stored in |v:termrfgresp|
  368. t_RB request terminal background color *t_RB* *'t_RB'*
  369. The response is stored in |v:termrbgresp|
  370. t_8f set foreground color (R, G, B) *t_8f* *'t_8f'*
  371. |xterm-true-color|
  372. t_8b set background color (R, G, B) *t_8b* *'t_8b'*
  373. |xterm-true-color|
  374. t_8u set underline color (R, G, B) *t_8u* *'t_8u'*
  375. t_BE enable bracketed paste mode *t_BE* *'t_BE'*
  376. |xterm-bracketed-paste|
  377. t_BD disable bracketed paste mode *t_BD* *'t_BD'*
  378. |xterm-bracketed-paste|
  379. t_SC set cursor color start *t_SC* *'t_SC'*
  380. t_EC set cursor color end *t_EC* *'t_EC'*
  381. t_SH set cursor shape *t_SH* *'t_SH'*
  382. t_RC request terminal cursor blinking *t_RC* *'t_RC'*
  383. The response is stored in |v:termblinkresp|
  384. t_RS request terminal cursor style *t_RS* *'t_RS'*
  385. The response is stored in |v:termstyleresp|
  386. t_ST save window title to stack *t_ST* *'t_ST'*
  387. t_RT restore window title from stack *t_RT* *'t_RT'*
  388. t_Si save icon text to stack *t_Si* *'t_Si'*
  389. t_Ri restore icon text from stack *t_Ri* *'t_Ri'*
  390. t_TE end of "raw" mode *t_TE* *'t_TE'*
  391. t_TI put terminal into "raw" mode *t_TI* *'t_TI'*
  392. t_fe enable focus-event tracking *t_fe* *'t_fe'*
  393. |xterm-focus-event|
  394. t_fd disable focus-event tracking *t_fd* *'t_fd'*
  395. |xterm-focus-event|
  396. Some codes have a start, middle and end part. The start and end are defined
  397. by the termcap option, the middle part is text.
  398. set title text: t_ts {title text} t_fs
  399. set icon text: t_IS {icon text} t_IE
  400. set cursor color: t_SC {color name} t_EC
  401. t_SH must take one argument:
  402. 0, 1 or none blinking block cursor
  403. 2 block cursor
  404. 3 blinking underline cursor
  405. 4 underline cursor
  406. 5 blinking vertical bar cursor
  407. 6 vertical bar cursor
  408. t_RS is sent only if the response to t_RV has been received. It is not used
  409. on Mac OS when Terminal.app could be recognized from the termresponse.
  410. KEY CODES *terminal-key-codes*
  411. Note: Use the <> form if possible
  412. option name meaning ~
  413. t_ku <Up> arrow up *t_ku* *'t_ku'*
  414. t_kd <Down> arrow down *t_kd* *'t_kd'*
  415. t_kr <Right> arrow right *t_kr* *'t_kr'*
  416. t_kl <Left> arrow left *t_kl* *'t_kl'*
  417. <xUp> alternate arrow up *<xUp>*
  418. <xDown> alternate arrow down *<xDown>*
  419. <xRight> alternate arrow right *<xRight>*
  420. <xLeft> alternate arrow left *<xLeft>*
  421. <S-Up> shift arrow up
  422. <S-Down> shift arrow down
  423. t_%i <S-Right> shift arrow right *t_%i* *'t_%i'*
  424. t_#4 <S-Left> shift arrow left *t_#4* *'t_#4'*
  425. t_k1 <F1> function key 1 *t_k1* *'t_k1'*
  426. <xF1> alternate F1 *<xF1>*
  427. t_k2 <F2> function key 2 *<F2>* *t_k2* *'t_k2'*
  428. <xF2> alternate F2 *<xF2>*
  429. t_k3 <F3> function key 3 *<F3>* *t_k3* *'t_k3'*
  430. <xF3> alternate F3 *<xF3>*
  431. t_k4 <F4> function key 4 *<F4>* *t_k4* *'t_k4'*
  432. <xF4> alternate F4 *<xF4>*
  433. t_k5 <F5> function key 5 *<F5>* *t_k5* *'t_k5'*
  434. t_k6 <F6> function key 6 *<F6>* *t_k6* *'t_k6'*
  435. t_k7 <F7> function key 7 *<F7>* *t_k7* *'t_k7'*
  436. t_k8 <F8> function key 8 *<F8>* *t_k8* *'t_k8'*
  437. t_k9 <F9> function key 9 *<F9>* *t_k9* *'t_k9'*
  438. t_k; <F10> function key 10 *<F10>* *t_k;* *'t_k;'*
  439. t_F1 <F11> function key 11 *<F11>* *t_F1* *'t_F1'*
  440. t_F2 <F12> function key 12 *<F12>* *t_F2* *'t_F2'*
  441. t_F3 <F13> function key 13 *<F13>* *t_F3* *'t_F3'*
  442. t_F4 <F14> function key 14 *<F14>* *t_F4* *'t_F4'*
  443. t_F5 <F15> function key 15 *<F15>* *t_F5* *'t_F5'*
  444. t_F6 <F16> function key 16 *<F16>* *t_F6* *'t_F6'*
  445. t_F7 <F17> function key 17 *<F17>* *t_F7* *'t_F7'*
  446. t_F8 <F18> function key 18 *<F18>* *t_F8* *'t_F8'*
  447. t_F9 <F19> function key 19 *<F19>* *t_F9* *'t_F9'*
  448. <S-F1> shifted function key 1
  449. <S-xF1> alternate <S-F1> *<S-xF1>*
  450. <S-F2> shifted function key 2 *<S-F2>*
  451. <S-xF2> alternate <S-F2> *<S-xF2>*
  452. <S-F3> shifted function key 3 *<S-F3>*
  453. <S-xF3> alternate <S-F3> *<S-xF3>*
  454. <S-F4> shifted function key 4 *<S-F4>*
  455. <S-xF4> alternate <S-F4> *<S-xF4>*
  456. <S-F5> shifted function key 5 *<S-F5>*
  457. <S-F6> shifted function key 6 *<S-F6>*
  458. <S-F7> shifted function key 7 *<S-F7>*
  459. <S-F8> shifted function key 8 *<S-F8>*
  460. <S-F9> shifted function key 9 *<S-F9>*
  461. <S-F10> shifted function key 10 *<S-F10>*
  462. <S-F11> shifted function key 11 *<S-F11>*
  463. <S-F12> shifted function key 12 *<S-F12>*
  464. t_%1 <Help> help key *t_%1* *'t_%1'*
  465. t_&8 <Undo> undo key *t_&8* *'t_&8'*
  466. t_kI <Insert> insert key *t_kI* *'t_kI'*
  467. t_kD <Del> delete key *t_kD* *'t_kD'*
  468. t_kb <BS> backspace key *t_kb* *'t_kb'*
  469. t_kB <S-Tab> back-tab (shift-tab) *<S-Tab>* *t_kB* *'t_kB'*
  470. t_kh <Home> home key *t_kh* *'t_kh'*
  471. t_#2 <S-Home> shifted home key *<S-Home>* *t_#2* *'t_#2'*
  472. <xHome> alternate home key *<xHome>*
  473. t_@7 <End> end key *t_@7* *'t_@7'*
  474. t_*7 <S-End> shifted end key *<S-End>* *t_star7* *'t_star7'*
  475. <xEnd> alternate end key *<xEnd>*
  476. t_kP <PageUp> page-up key *t_kP* *'t_kP'*
  477. t_kN <PageDown> page-down key *t_kN* *'t_kN'*
  478. t_K1 <kHome> keypad home key *t_K1* *'t_K1'*
  479. t_K4 <kEnd> keypad end key *t_K4* *'t_K4'*
  480. t_K3 <kPageUp> keypad page-up key *t_K3* *'t_K3'*
  481. t_K5 <kPageDown> keypad page-down key *t_K5* *'t_K5'*
  482. t_K6 <kPlus> keypad plus key *<kPlus>* *t_K6* *'t_K6'*
  483. t_K7 <kMinus> keypad minus key *<kMinus>* *t_K7* *'t_K7'*
  484. t_K8 <kDivide> keypad divide *<kDivide>* *t_K8* *'t_K8'*
  485. t_K9 <kMultiply> keypad multiply *<kMultiply>* *t_K9* *'t_K9'*
  486. t_KA <kEnter> keypad enter key *<kEnter>* *t_KA* *'t_KA'*
  487. t_KB <kPoint> keypad decimal point *<kPoint>* *t_KB* *'t_KB'*
  488. t_KC <k0> keypad 0 *<k0>* *t_KC* *'t_KC'*
  489. t_KD <k1> keypad 1 *<k1>* *t_KD* *'t_KD'*
  490. t_KE <k2> keypad 2 *<k2>* *t_KE* *'t_KE'*
  491. t_KF <k3> keypad 3 *<k3>* *t_KF* *'t_KF'*
  492. t_KG <k4> keypad 4 *<k4>* *t_KG* *'t_KG'*
  493. t_KH <k5> keypad 5 *<k5>* *t_KH* *'t_KH'*
  494. t_KI <k6> keypad 6 *<k6>* *t_KI* *'t_KI'*
  495. t_KJ <k7> keypad 7 *<k7>* *t_KJ* *'t_KJ'*
  496. t_KK <k8> keypad 8 *<k8>* *t_KK* *'t_KK'*
  497. t_KL <k9> keypad 9 *<k9>* *t_KL* *'t_KL'*
  498. <Mouse> leader of mouse code *<Mouse>*
  499. *t_PS* *'t_PS'*
  500. t_PS start of bracketed paste |xterm-bracketed-paste|
  501. t_PE end of bracketed paste |xterm-bracketed-paste| *t_PE* *'t_PE'*
  502. Note about t_so and t_mr: When the termcap entry "so" is not present the
  503. entry for "mr" is used. And vice versa. The same is done for "se" and "me".
  504. If your terminal supports both inversion and standout mode, you can see two
  505. different modes. If your terminal supports only one of the modes, both will
  506. look the same.
  507. *keypad-comma*
  508. The keypad keys, when they are not mapped, behave like the equivalent normal
  509. key. There is one exception: if you have a comma on the keypad instead of a
  510. decimal point, Vim will use a dot anyway. Use these mappings to fix that: >
  511. :noremap <kPoint> ,
  512. :noremap! <kPoint> ,
  513. < *xterm-codes*
  514. There is a special trick to obtain the key codes which currently only works
  515. for xterm. When |t_RV| is defined and a response is received which indicates
  516. an xterm with patchlevel 141 or higher, Vim uses special escape sequences to
  517. request the key codes directly from the xterm. The responses are used to
  518. adjust the various t_ codes. This avoids the problem that the xterm can
  519. produce different codes, depending on the mode it is in (8-bit, VT102,
  520. VT220, etc.). The result is that codes like <xF1> are no longer needed.
  521. One of the codes that can change is 't_Co', the number of colors. This will
  522. trigger a redraw. If this is a problem, reset the 'xtermcodes' option as
  523. early as possible: >
  524. set noxtermcodes
  525. Note: Requesting the key codes is only done on startup. If the xterm options
  526. are changed after Vim has started, the escape sequences may not be recognized
  527. anymore.
  528. *xterm-true-color*
  529. Vim supports using true colors in the terminal (taken from |highlight-guifg|
  530. and |highlight-guibg|), given that the terminal supports this. To make this
  531. work the 'termguicolors' option needs to be set.
  532. See https://github.com/termstandard/colors for a list of terminals that
  533. support true colors.
  534. Sometimes setting 'termguicolors' is not enough and one has to set the |t_8f|
  535. and |t_8b| options explicitly. Default values of these options are
  536. "^[[38;2;%lu;%lu;%lum" and "^[[48;2;%lu;%lu;%lum" respectively, but it is only
  537. set when `$TERM` is `xterm`. Some terminals accept the same sequences, but
  538. with all semicolons replaced by colons (this is actually more compatible, but
  539. less widely supported): >
  540. let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
  541. let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
  542. These options contain printf strings, with |printf()| (actually, its C
  543. equivalent hence `l` modifier) invoked with the t_ option value and three
  544. unsigned long integers that may have any value between 0 and 255 (inclusive)
  545. representing red, green and blue colors respectively.
  546. *xterm-resize*
  547. Window resizing with xterm only works if the allowWindowOps resource is
  548. enabled. On some systems and versions of xterm it's disabled by default
  549. because someone thought it would be a security issue. It's not clear if this
  550. is actually the case.
  551. To overrule the default, put this line in your ~/.Xdefaults or
  552. ~/.Xresources:
  553. >
  554. XTerm*allowWindowOps: true
  555. And run "xrdb -merge .Xresources" to make it effective. You can check the
  556. value with the context menu (right mouse button while CTRL key is pressed),
  557. there should be a tick at allow-window-ops.
  558. *xterm-focus-event*
  559. Some terminals including xterm support the focus event tracking feature.
  560. If this feature is enabled by the 't_fe' sequence, special key sequences are
  561. sent from the terminal to Vim every time the terminal gains or loses focus.
  562. Vim fires focus events (|FocusGained|/|FocusLost|) by handling them accordingly.
  563. Focus event tracking is disabled by a 't_fd' sequence when exiting "raw" mode.
  564. If you would like to disable this feature, add the following to your .vimrc:
  565. `set t_fd=`
  566. `set t_fe=`
  567. If your terminal does support this but Vim does not recognize the terminal,
  568. you may have to set the options yourself: >
  569. let &t_fe = "\<Esc>[?1004h"
  570. let &t_fd = "\<Esc>[?1004l"
  571. execute "set <FocusGained>=\<Esc>[I"
  572. execute "set <FocusLost>=\<Esc>[O"
  573. If this causes garbage to show when Vim starts up then it doesn't work.
  574. *termcap-colors*
  575. Note about colors: The 't_Co' option tells Vim the number of colors available.
  576. When it is non-zero, the 't_AB' and 't_AF' options are used to set the color.
  577. If one of these is not available, 't_Sb' and 't_Sf' are used. 't_me' is used
  578. to reset to the default colors. Also see 'termguicolors'.
  579. When the GUI is running 't_Co' is set to 16777216.
  580. *termcap-cursor-shape* *termcap-cursor-color*
  581. When Vim enters Insert mode the 't_SI' escape sequence is sent. When Vim
  582. enters Replace mode the 't_SR' escape sequence is sent if it is set, otherwise
  583. 't_SI' is sent. When leaving Insert mode or Replace mode 't_EI' is used.
  584. Note: When 't_EI' is not set then 't_SI' and 't_SR' will not be sent. And
  585. when 't_SI' or 't_SR' is not set then 't_EI' is sent only once.
  586. This can be used to change the shape or color of the cursor in Insert or
  587. Replace mode. These are not standard termcap/terminfo entries, you need to set
  588. them yourself.
  589. Example for an xterm, this changes the color of the cursor: >
  590. if &term =~ "xterm"
  591. let &t_SI = "\<Esc>]12;purple\x7"
  592. let &t_SR = "\<Esc>]12;red\x7"
  593. let &t_EI = "\<Esc>]12;blue\x7"
  594. endif
  595. NOTE: When Vim exits the shape for Normal mode will remain. The shape from
  596. before Vim started will not be restored.
  597. For Windows Terminal you can use something like this: >
  598. " Note: This should be set after `set termguicolors` or `set t_Co=256`.
  599. if &term =~ 'xterm' || &term == 'win32'
  600. " Use DECSCUSR escape sequences
  601. let &t_SI = "\e[5 q" " blink bar
  602. let &t_SR = "\e[3 q" " blink underline
  603. let &t_EI = "\e[1 q" " blink block
  604. let &t_ti ..= "\e[1 q" " blink block
  605. let &t_te ..= "\e[0 q" " default (depends on terminal, normally blink block)
  606. endif
  607. {not available when compiled without the |+cursorshape| feature}
  608. *termcap-title*
  609. The 't_ts' and 't_fs' options are used to set the window title if the terminal
  610. allows title setting via sending strings. They are sent before and after the
  611. title string, respectively. Similar 't_IS' and 't_IE' are used to set the
  612. icon text. These are Vim-internal extensions of the Unix termcap, so they
  613. cannot be obtained from an external termcap. However, the builtin termcap
  614. contains suitable entries for xterm and iris-ansi, so you don't need to set
  615. them here.
  616. *hpterm*
  617. If inversion or other highlighting does not work correctly, try setting the
  618. 't_xs' option to a non-empty string. This makes the 't_ce' code be used to
  619. remove highlighting from a line. This is required for "hpterm". Setting the
  620. 'weirdinvert' option has the same effect as making 't_xs' non-empty, and vice
  621. versa.
  622. *scroll-region*
  623. Some termcaps do not include an entry for "cs" (scroll region), although the
  624. terminal does support it. For example: xterm on a Sun. You can use the
  625. builtin_xterm or define t_cs yourself. For example: >
  626. :set t_cs=^V^[[%i%d;%dr
  627. Where ^V is CTRL-V and ^[ is <Esc>.
  628. The vertical scroll region t_CV is not a standard termcap code. Vim uses it
  629. internally in the GUI. But it can also be defined for a terminal, if you can
  630. find one that supports it. The two arguments are the left and right column of
  631. the region which to restrict the scrolling to. Just like t_cs defines the top
  632. and bottom lines. Defining t_CV will make scrolling in vertically split
  633. windows a lot faster. Don't set t_CV when t_da or t_db is set (text isn't
  634. cleared when scrolling).
  635. Unfortunately it is not possible to deduce from the termcap how cursor
  636. positioning should be done when using a scrolling region: Relative to the
  637. beginning of the screen or relative to the beginning of the scrolling region.
  638. Most terminals use the first method. The 't_CS' option should be set to any
  639. string when cursor positioning is relative to the start of the scrolling
  640. region. It should be set to an empty string otherwise.
  641. Note for xterm users: The shifted cursor keys normally don't work. You can
  642. make them work with the xmodmap command and some mappings in Vim.
  643. Give these commands in the xterm:
  644. xmodmap -e "keysym Up = Up F13"
  645. xmodmap -e "keysym Down = Down F16"
  646. xmodmap -e "keysym Left = Left F18"
  647. xmodmap -e "keysym Right = Right F19"
  648. And use these mappings in Vim:
  649. :map <t_F3> <S-Up>
  650. :map! <t_F3> <S-Up>
  651. :map <t_F6> <S-Down>
  652. :map! <t_F6> <S-Down>
  653. :map <t_F8> <S-Left>
  654. :map! <t_F8> <S-Left>
  655. :map <t_F9> <S-Right>
  656. :map! <t_F9> <S-Right>
  657. Instead of, say, <S-Up> you can use any other command that you want to use the
  658. shift-cursor-up key for. (Note: To help people that have a Sun keyboard with
  659. left side keys F14 is not used because it is confused with the undo key; F15
  660. is not used, because it does a window-to-front; F17 is not used, because it
  661. closes the window. On other systems you can probably use them.)
  662. ==============================================================================
  663. 3. Window size *window-size*
  664. [This is about the size of the whole window Vim is using, not a window that is
  665. created with the ":split" command.]
  666. If you are running Vim on an Amiga and the terminal name is "amiga" or
  667. "builtin_amiga", the amiga-specific window resizing will be enabled. On Unix
  668. systems three methods are tried to get the window size:
  669. - an ioctl call (TIOCGSIZE or TIOCGWINSZ, depends on your system)
  670. - the environment variables "LINES" and "COLUMNS"
  671. - from the termcap entries "li" and "co"
  672. If everything fails a default size of 24 lines and 80 columns is assumed. If
  673. a window-resize signal is received the size will be set again. If the window
  674. size is wrong you can use the 'lines' and 'columns' options to set the
  675. correct values.
  676. One command can be used to set the screen size:
  677. *:mod* *:mode* *E359*
  678. :mod[e] [mode]
  679. Without argument this only detects the screen size and redraws the screen.
  680. [mode] was used on MS-DOS, but it doesn't work anymore. In |Vim9| this
  681. command is not supported.
  682. ==============================================================================
  683. 4. Slow and fast terminals *slow-fast-terminal*
  684. *slow-terminal*
  685. If you have a fast terminal you may like to set the 'ruler' option. The
  686. cursor position is shown in the status line. If you are using horizontal
  687. scrolling ('wrap' option off) consider setting 'sidescroll' to a small
  688. number.
  689. If you have a slow terminal you may want to reset the 'showcmd' option.
  690. The command characters will not be shown in the status line. If the terminal
  691. scrolls very slowly, set the 'scrolljump' to 5 or so. If the cursor is moved
  692. off the screen (e.g., with "j") Vim will scroll 5 lines at a time. Another
  693. possibility is to reduce the number of lines that Vim uses with the command
  694. "z{height}<CR>".
  695. If the characters from the terminal are arriving with more than 1 second
  696. between them you might want to set the 'timeout' and/or 'ttimeout' option.
  697. See the "Options" chapter |options|.
  698. If your terminal does not support a scrolling region, but it does support
  699. insert/delete line commands, scrolling with multiple windows may make the
  700. lines jump up and down. This would happen if the 'ttyfast' option has been
  701. reset. Check that with: >
  702. verbose set ttyfast?
  703. If your terminal scrolls very slowly, but redrawing is not slow, set the
  704. 'ttyscroll' option to a small number, e.g., 3. This will make Vim redraw the
  705. screen instead of scrolling, when there are more than 3 lines to be scrolled.
  706. If you are using a color terminal that is slow, use this command: >
  707. hi NonText cterm=NONE ctermfg=NONE
  708. This avoids that spaces are sent when they have different attributes. On most
  709. terminals you can't see this anyway.
  710. If you are using Vim over a slow serial line, you might want to try running
  711. Vim inside the "screen" program. Screen will optimize the terminal I/O quite
  712. a bit.
  713. If you are testing termcap options, but you cannot see what is happening, you
  714. might want to set the 'writedelay' option. When non-zero, one character is
  715. sent to the terminal at a time. This makes the screen updating a lot slower,
  716. making it possible to see what is happening.
  717. ==============================================================================
  718. 5. Using the mouse *mouse-using*
  719. This section is about using the mouse on a terminal or a terminal window. How
  720. to use the mouse in a GUI window is explained in |gui-mouse|. For scrolling
  721. with a mouse wheel see |scroll-mouse-wheel|.
  722. Don't forget to enable the mouse with this command: >
  723. :set mouse=a
  724. Otherwise Vim won't recognize the mouse in all modes (See 'mouse').
  725. Currently the mouse is supported for Unix in an xterm window, in a *BSD
  726. console with |sysmouse|, in a Linux console (with GPM |gpm-mouse|), and
  727. in a Windows console.
  728. Mouse clicks can be used to position the cursor, select an area and paste.
  729. These characters in the 'mouse' option tell in which situations the mouse will
  730. be used by Vim:
  731. n Normal mode
  732. v Visual mode
  733. i Insert mode
  734. c Command-line mode
  735. h all previous modes when in a help file
  736. a all previous modes
  737. r for |hit-enter| prompt
  738. The default for 'mouse' is empty, the mouse is not used. Normally you would
  739. do: >
  740. :set mouse=a
  741. to start using the mouse (this is equivalent to setting 'mouse' to "nvich").
  742. If you only want to use the mouse in a few modes or also want to use it for
  743. the two questions you will have to concatenate the letters for those modes.
  744. For example: >
  745. :set mouse=nv
  746. Will make the mouse work in Normal mode and Visual mode. >
  747. :set mouse=h
  748. Will make the mouse work in help files only (so you can use "g<LeftMouse>" to
  749. jump to tags).
  750. Whether the selection that is started with the mouse is in Visual mode or
  751. Select mode depends on whether "mouse" is included in the 'selectmode'
  752. option.
  753. *terminal-mouse*
  754. In an xterm, with the currently active mode included in the 'mouse' option,
  755. normal mouse clicks are used by Vim, mouse clicks with the shift or ctrl key
  756. pressed go to the xterm. With the currently active mode not included in
  757. 'mouse' all mouse clicks go to the xterm.
  758. For terminals where it is not possible to have the mouse events be used by the
  759. terminal itself by using a modifier, a workaround is to not use mouse events
  760. for Vim in command-line mode: >
  761. :set mouse=nvi
  762. Then to select text with the terminal, use ":" to go to command-line mode,
  763. select and copy the text to the system, then press Esc.
  764. Another way is to temporarily use ":sh" to run a shell, copy the text, then
  765. exit the shell. 'mouse' can remain set to "a" then.
  766. *xterm-clipboard*
  767. In the Motif GUI version, when running in a terminal and there is
  768. access to the X-server (DISPLAY is set), the copy and paste will behave like
  769. in the GUI. If not, the middle mouse button will insert the unnamed register.
  770. In that case, here is how you copy and paste a piece of text:
  771. Copy/paste with the mouse and Visual mode ('mouse' option must be set, see
  772. above):
  773. 1. Press left mouse button on first letter of text, move mouse pointer to last
  774. letter of the text and release the button. This will start Visual mode and
  775. highlight the selected area.
  776. 2. Press "y" to yank the Visual text in the unnamed register.
  777. 3. Click the left mouse button at the insert position.
  778. 4. Click the middle mouse button.
  779. Shortcut: If the insert position is on the screen at the same time as the
  780. Visual text, you can do 2, 3 and 4 all in one: Click the middle mouse button
  781. at the insert position.
  782. Note: When the |-X| command line argument is used, Vim will not connect to the
  783. X server and copy/paste to the X clipboard (selection) will not work. Use the
  784. shift key with the mouse buttons to let the xterm do the selection.
  785. *xterm-command-server*
  786. When the X-server clipboard is available, the command server described in
  787. |x11-clientserver| can be enabled with the --servername command line argument.
  788. *xterm-copy-paste*
  789. NOTE: In some (older) xterms, it's not possible to move the cursor past column
  790. 95 or 223. This is an xterm problem, not Vim's. Get a newer xterm
  791. |color-xterm|. Also see |'ttymouse'|.
  792. Copy/paste in xterm with (current mode NOT included in 'mouse'):
  793. 1. Press left mouse button on first letter of text, move mouse pointer to last
  794. letter of the text and release the button.
  795. 2. Use normal Vim commands to put the cursor at the insert position.
  796. 3. Press "a" to start Insert mode.
  797. 4. Click the middle mouse button.
  798. 5. Press ESC to end Insert mode.
  799. (The same can be done with anything in 'mouse' if you keep the shift key
  800. pressed while using the mouse.)
  801. Note: if you lose the 8th bit when pasting (special characters are translated
  802. into other characters), you may have to do "stty cs8 -istrip -parenb" in your
  803. shell before starting Vim.
  804. Thus in an xterm the shift and ctrl keys cannot be used with the mouse. Mouse
  805. commands requiring the CTRL modifier can be simulated by typing the "g" key
  806. before using the mouse:
  807. "g<LeftMouse>" is "<C-LeftMouse> (jump to tag under mouse click)
  808. "g<RightMouse>" is "<C-RightMouse> ("CTRL-T")
  809. *mouse-mode-table* *mouse-overview*
  810. A short overview of what the mouse buttons do, when 'mousemodel' is "extend":
  811. Normal Mode:
  812. event position selection change action ~
  813. cursor window ~
  814. <LeftMouse> yes end yes
  815. <C-LeftMouse> yes end yes "CTRL-]" (2)
  816. <S-LeftMouse> yes no change yes "*" (2) *<S-LeftMouse>*
  817. <LeftDrag> yes start or extend (1) no *<LeftDrag>*
  818. <LeftRelease> yes start or extend (1) no
  819. <MiddleMouse> yes if not active no put
  820. <MiddleMouse> yes if active no yank and put
  821. <RightMouse> yes start or extend yes
  822. <A-RightMouse> yes start or extend blockw. yes *<A-RightMouse>*
  823. <S-RightMouse> yes no change yes "#" (2) *<S-RightMouse>*
  824. <C-RightMouse> no no change no "CTRL-T"
  825. <RightDrag> yes extend no *<RightDrag>*
  826. <RightRelease> yes extend no *<RightRelease>*
  827. Insert or Replace Mode:
  828. event position selection change action ~
  829. cursor window ~
  830. <LeftMouse> yes (cannot be active) yes
  831. <C-LeftMouse> yes (cannot be active) yes "CTRL-O^]" (2)
  832. <S-LeftMouse> yes (cannot be active) yes "CTRL-O*" (2)
  833. <LeftDrag> yes start or extend (1) no like CTRL-O (1)
  834. <LeftRelease> yes start or extend (1) no like CTRL-O (1)
  835. <MiddleMouse> no (cannot be active) no put register
  836. <RightMouse> yes start or extend yes like CTRL-O
  837. <A-RightMouse> yes start or extend blockw. yes
  838. <S-RightMouse> yes (cannot be active) yes "CTRL-O#" (2)
  839. <C-RightMouse> no (cannot be active) no "CTRL-O CTRL-T"
  840. In a help window:
  841. event position selection change action ~
  842. cursor window ~
  843. <2-LeftMouse> yes (cannot be active) no "^]" (jump to help tag)
  844. When 'mousemodel' is "popup", these are different:
  845. Normal Mode:
  846. event position selection change action ~
  847. cursor window ~
  848. <S-LeftMouse> yes start or extend (1) no
  849. <A-LeftMouse> yes start or extend blockw. no *<A-LeftMouse>*
  850. <RightMouse> no popup menu no
  851. Insert or Replace Mode:
  852. event position selection change action ~
  853. cursor window ~
  854. <S-LeftMouse> yes start or extend (1) no like CTRL-O (1)
  855. <A-LeftMouse> yes start or extend blockw. no
  856. <RightMouse> no popup menu no
  857. (1) only if mouse pointer moved since press
  858. (2) only if click is in same buffer
  859. Clicking the left mouse button causes the cursor to be positioned. If the
  860. click is in another window that window is made the active window. When
  861. editing the command-line the cursor can only be positioned on the
  862. command-line. When in Insert mode Vim remains in Insert mode. If 'scrolloff'
  863. is set, and the cursor is positioned within 'scrolloff' lines from the window
  864. border, the text is scrolled.
  865. A selection can be started by pressing the left mouse button on the first
  866. character, moving the mouse to the last character, then releasing the mouse
  867. button. You will not always see the selection until you release the button,
  868. only in some versions (GUI, Win32) will the dragging be shown immediately.
  869. Note that you can make the text scroll by moving the mouse at least one
  870. character in the first/last line in the window when 'scrolloff' is non-zero.
  871. In Normal, Visual and Select mode clicking the right mouse button causes the
  872. Visual area to be extended. When 'mousemodel' is "popup", the left button has
  873. to be used while keeping the shift key pressed. When clicking in a window
  874. which is editing another buffer, the Visual or Select mode is stopped.
  875. In Normal, Visual and Select mode clicking the right mouse button with the alt
  876. key pressed causes the Visual area to become blockwise. When 'mousemodel' is
  877. "popup" the left button has to be used with the alt key. Note that this won't
  878. work on systems where the window manager consumes the mouse events when the
  879. alt key is pressed (it may move the window).
  880. *double-click*
  881. Double, triple and quadruple clicks are supported when the GUI is active, for
  882. Win32, and for an xterm (if the gettimeofday() function is available). For
  883. selecting text, extra clicks extend the selection:
  884. click select ~
  885. double word or % match *<2-LeftMouse>*
  886. triple line *<3-LeftMouse>*
  887. quadruple rectangular block *<4-LeftMouse>*
  888. Exception: In a Help window a double click jumps to help for the word that is
  889. clicked on.
  890. A double click on a word selects that word. 'iskeyword' is used to specify
  891. which characters are included in a word. A double click on a character
  892. that has a match selects until that match (like using "v%"). If the match is
  893. an #if/#else/#endif block, the selection becomes linewise.
  894. For MS-Windows and xterm the time for double clicking can be set with the
  895. 'mousetime' option. For the other systems this time is defined outside of Vim.
  896. An example, for using a double click to jump to the tag under the cursor: >
  897. :map <2-LeftMouse> :exe "tag " .. expand("<cword>")<CR>
  898. Dragging the mouse with a double click (button-down, button-up, button-down
  899. and then drag) will result in whole words to be selected. This continues
  900. until the button is released, at which point the selection is per character
  901. again.
  902. For scrolling with the mouse see |scroll-mouse-wheel|.
  903. *gpm-mouse*
  904. The GPM mouse is only supported when the |+mouse_gpm| feature was enabled at
  905. compile time. The GPM mouse driver (Linux console) does not support quadruple
  906. clicks.
  907. In Insert mode, when a selection is started, Vim goes into Normal mode
  908. temporarily. When Visual or Select mode ends, it returns to Insert mode.
  909. This is like using CTRL-O in Insert mode. Select mode is used when the
  910. 'selectmode' option contains "mouse".
  911. *sysmouse*
  912. The sysmouse is only supported when the |+mouse_sysmouse| feature was enabled
  913. at compile time. The sysmouse driver (*BSD console) does not support keyboard
  914. modifiers.
  915. *drag-status-line*
  916. When working with several windows, the size of the windows can be changed by
  917. dragging the status line with the mouse. Point the mouse at a status line,
  918. press the left button, move the mouse to the new position of the status line,
  919. release the button. Just clicking the mouse in a status line makes that window
  920. the current window, without moving the cursor. If by selecting a window it
  921. will change position or size, the dragging of the status line will look
  922. confusing, but it will work (just try it).
  923. *<MiddleRelease>* *<MiddleDrag>*
  924. Mouse clicks can be mapped. The codes for mouse clicks are:
  925. code mouse button normal action ~
  926. <LeftMouse> left pressed set cursor position
  927. <LeftDrag> left moved while pressed extend selection
  928. <LeftRelease> left released set selection end
  929. <MiddleMouse> middle pressed paste text at cursor position
  930. <MiddleDrag> middle moved while pressed -
  931. <MiddleRelease> middle released -
  932. <RightMouse> right pressed extend selection
  933. <RightDrag> right moved while pressed extend selection
  934. <RightRelease> right released set selection end
  935. <X1Mouse> X1 button pressed - *X1Mouse*
  936. <X1Drag> X1 moved while pressed - *X1Drag*
  937. <X1Release> X1 button release - *X1Release*
  938. <X2Mouse> X2 button pressed - *X2Mouse*
  939. <X2Drag> X2 moved while pressed - *X2Drag*
  940. <X2Release> X2 button release - *X2Release*
  941. The X1 and X2 buttons refer to the extra buttons found on some mice. The
  942. 'Microsoft Explorer' mouse has these buttons available to the right thumb.
  943. Currently X1 and X2 only work on Win32 and X11 environments.
  944. Examples: >
  945. :noremap <MiddleMouse> <LeftMouse><MiddleMouse>
  946. Paste at the position of the middle mouse button click (otherwise the paste
  947. would be done at the cursor position). >
  948. :noremap <LeftRelease> <LeftRelease>y
  949. Immediately yank the selection, when using Visual mode.
  950. Note the use of ":noremap" instead of "map" to avoid a recursive mapping.
  951. >
  952. :map <X1Mouse> <C-O>
  953. :map <X2Mouse> <C-I>
  954. Map the X1 and X2 buttons to go forwards and backwards in the jump list, see
  955. |CTRL-O| and |CTRL-I|.
  956. *mouse-swap-buttons*
  957. To swap the meaning of the left and right mouse buttons: >
  958. :noremap <LeftMouse> <RightMouse>
  959. :noremap <LeftDrag> <RightDrag>
  960. :noremap <LeftRelease> <RightRelease>
  961. :noremap <RightMouse> <LeftMouse>
  962. :noremap <RightDrag> <LeftDrag>
  963. :noremap <RightRelease> <LeftRelease>
  964. :noremap g<LeftMouse> <C-RightMouse>
  965. :noremap g<RightMouse> <C-LeftMouse>
  966. :noremap! <LeftMouse> <RightMouse>
  967. :noremap! <LeftDrag> <RightDrag>
  968. :noremap! <LeftRelease> <RightRelease>
  969. :noremap! <RightMouse> <LeftMouse>
  970. :noremap! <RightDrag> <LeftDrag>
  971. :noremap! <RightRelease> <LeftRelease>
  972. <
  973. vim:tw=78:ts=8:noet:ft=help:norl: