📄 term.txt
字号:
*term.txt* For Vim version 5.8. Last change: 2000 Dec 02 VIM REFERENCE MANUAL by Bram MoolenaarTerminal information *terminal-info*Vim uses information about the terminal you are using to fill the screen andrecognize what keys you hit. If this information is not correct the screenmay be messed up or keys may not be recognized. The actions which have to beperformed on the screen are accomplished by outputting a string ofcharacters. Special keys produce a string of characters. These strings arestored in the terminal options, see |terminal-options|.NOTE: Most of this is not used when running the |GUI|.1. Startup |startup-terminal|2. Terminal options |terminal-options|3. Window size |window-size|4. Slow and fast terminals |slow-fast-terminal|5. Using the mouse |mouse-using|==============================================================================1. Startup *startup-terminal*When Vim is started a default terminal type is assumed. For the Amiga this isa standard CLI window, for MS-DOS the pc terminal, for Unix an ansi terminal.A few other terminal types are always available, see below |builtin-terms|.You can give the terminal name with the '-T' Vim argument. If it is not givenVim will try to get the name from the TERM environment variable. *termcap* *terminfo*On Unix the terminfo database or termcap file is used. This is referred to as"termcap" in all the documentation. At compile time, when running configure,the choice whether to use terminfo or termcap is done automatically. Whenrunning Vim the output of ":version" will show |+terminfo| if terminfo isused. Also see |xterm-screens|.On non-Unix systems a termcap is only available if Vim was compiled withTERMCAP defined. *builtin-terms* *builtin_terms*Which builtin terminals are available depends on a few defines in feature.h,which needs to be set at compile time: define output of ":version" terminals builtin ~NO_BUILTIN_TCAPS -builtin_terms noneSOME_BUILTIN_TCAPS +builtin_terms most common ones (default)ALL_BUILTIN_TCAPS ++builtin_terms all availableYou can see a list of available builtin terminals with ":set term=xxx" (whennot running the GUI). Also see |+builtin_terms|.If the termcap code is included Vim will try to get the strings for theterminal you are using from the termcap file and the builtin termcaps. Bothare always used, if an entry for the terminal you are using is present. Whichone is used first depends on the 'ttybuiltin' option:'ttybuiltin' on 1: builtin termcap 2: external termcap'ttybuiltin' off 1: external termcap 2: builtin termcapIf an option is missing in one of them, it will be obtained from the otherone. If an option is present in both, the one first encountered is used.Which external termcap file is used varies from system to system and maydepend on the environment variables "TERMCAP" and "TERMPATH". See "mantgetent".Settings depending on terminal *term-dependent-settings*If you want to set options or mappings, depending on the terminal name, youcan do this best in your .vimrc. Example:> if &term == "xterm"> ... xterm maps and settings ...> elseif &term =~ "vt10."> ... vt100, vt102 maps and settings ...> endif *raw-terminal-mode*For normal editing the terminal will be put into "raw" mode. The stringsdefined with 't_ti' and 't_ks' will be sent to the terminal. Normally thisputs the terminal in a state where the termcap codes are valid and activatesthe cursor and function keys. When Vim exits the terminal will be put backinto the mode it was before Vim started. The strings defined with 't_te' and't_ke' will be sent to the terminal. On the Amiga with commands that executean external command (e.g., "!!") the terminal will be put into Normal mode fora moment. This means that you can stop the output to the screen by hitting aprinting key. Output resumes when you hit <BS>. *cs7-problem*Note: If the terminal settings are changed after running Vim, you might havean illegal combination of settings. This has been reported on Solaris 2.5with "stty cs8 parenb", which is restored as "stty cs7 parenb". Use"stty cs8 -parenb -istrip" instead, this is restored correctly.Some termcap entries are wrong in the sense that after sending 't_ks' thecursor keys send codes different from the codes defined in the termcap. Toavoid this you can set 't_ks' (and 't_ke') to empty strings. This must bedone during initialization (see |initialization|), otherwise its too late.Some termcap entries assume that the highest bit is always reset. Forexample: The cursor-up entry for the amiga could be ":ku=\EA:". But the Amigareally sends "\233A". This works fine if the highest bit is reset, e.g., whenusing an Amiga over a serial line. If the cursor keys don't work, try theentry ":ku=\233A:".Some termcap entries have the entry ":ku=\E[A:". But the Amiga really sends"\233A". On output "\E[" and "\233" are often equivalent, on input theyaren't. You will have to change the termcap entry, or change the key code withthe :set command to fix this.Many cursor key codes start with an <Esc>. Vim must find out if this a singlehit of the <Esc> key or the start of a cursor key sequence. It waits for anext character to arrive. If it does not arrive within one second a single<Esc> is assumed. On very slow systems this may fail, causing cursor keys notto work sometimes. If you discover this problem reset the 'timeout' option.Vim will wait for the next character to arrive after an <Esc>. If you want toenter a single <Esc> you must type it twice. Resetting the 'esckeys' optionavoids this problems in Insert mode, but you lose the possibility to usecursor and function keys in Insert mode.On the Amiga the recognition of window resizing is activated only when theterminal name is "amiga" or "builtin_amiga".Some terminals have confusing codes for the cursor keys. The televideo 925 issuch a terminal. It sends a CTRL-H for cursor-left. This would make itimpossible to distinguish a backspace and cursor-left. To avoid this problemCTRL-H is never recognized as cursor-left. *vt100-cursor-keys* *xterm-cursor-keys*Other terminals (e.g., vt100 and xterm) have cursor keys that send <Esc>OA,<Esc>OB, etc. Unfortunately these are valid commands in insert mode: Stopinsert, Open a new line above the new one, start inserting 'A', 'B', etc.Instead of performing these commands Vim will erroneously recognize this typedkey sequence as a cursor key movement. To avoid this and make Vim do what youwant in either case you could use these settings: :set notimeout " don't timeout on mappings :set ttimeout " do timeout on terminal key codes :set timeoutlen=100 " timemout in 100 msecThis requires the key-codes to be send within 100msec in order to recognizethem as a cursor key. When you type you normally are not that fast, so theyare recognized as individual typed commands, even though Vim receives the samesequence of bytes. *vt100-function-keys* *xterm-function-keys*An xterm can send function keys F1 to F4 in two modes: vt100 compatible ornot. Because Vim cannot know what the xterm is sending, both types of keysare recognized. The same happens for the <Home> and <End> keys. normal vt100 ~ <F1> t_k1 <Esc>[11~ <xF1> <Esc>OP *<xF1>-xterm* <F2> t_k2 <Esc>[12~ <xF2> <Esc>OQ *<xF2>-xterm* <F3> t_k3 <Esc>[13~ <xF3> <Esc>OR *<xF3>-xterm* <F4> t_k4 <Esc>[14~ <xF4> <Esc>OS *<xF4>-xterm* <Home> t_kh <Esc>[7~ <xHome> <Esc>OH *<xHome>-xterm* <End> t_@7 <Esc>[4~ <xEnd> <Esc>OF *<xEnd>-xterm*When Vim starts, <xF1> is mapped to <F1>, <xF2> to <F2> etc. This means thatby default both codes to the same thing. If you make a mapping for <xF2>,because your terminal does have two keys, the default mapping is overwritten,thus you can use the <F2> and <xF2> keys for something different. *xterm-shifted-keys*Newer versions of xterm support shifted function keys and special keys. Vimrecognizes most of them. Use ":set termcap" to check which are supported andwhat the codes are. Mostly these are not in a termcap, they are onlysupported by the builtin_xterm termcap. *xterm-scroll-region*The default termcap entry for xterm on sun and other platforms does notcontain the entry for scroll regions. Add ":cs=\E[%i%d;%dr:" to the xtermentry in /etc/termcap and everything should work. *xterm-end-home-keys*On some systems (at least on FreeBSD with X386 3.1.2) the codes that the <End>and <Home> keys send contain a <Nul> character. To make these keys send theproper key code, add these lines to your ~/.Xdefaults file:*VT100.Translations: #override \n\ <Key>Home: string("0x1b") string("[7~") \n\ <Key>End: string("0x1b") string("[8~") *xterm-8bit*Xterm can be run in a mode where it uses 8bit escape sequences. The CSI odeis used instead of <Esc>[. The advantage is that an <Esc> can quickly berecognized in Insert mode, because it can't be confused with the start of aspecial key.For the builtin termcap entries, Vim checks if the 'term' option contains"8bit" anywhere. It then uses 8-bit characters for the termcap entries, themouse and a few other things. You would normally set $TERM in your shell to"xterm-8bit" and Vim picks this up and adjusts to the 8-bit settingautomatically.==============================================================================2. Terminal options *terminal-options*The terminal options can be set just like normal options. But they are notshown with the ":set all" command. Instead use ":set termcap".It is always possible to change individual strings by setting theappropriate option. For example:> :set t_ce=^V^[[K (CTRL-V, <Esc>, [, K){Vi: no terminal options. You have to exit Vi, edit the termcap entry andtry again}The options are listed below. The associated termcap code is always equal tothe last two characters of the option name. Two termcap codes are required:Cursor positioning and clear screen.The options 't_da', 't_db', 't_ms', 't_xs' represent flags in the termcap.When the termcap flag is present, the option will be set to "y". But anynon-empty string means that the flag is set. An empty string means that theflag is not set. 't_CS' works like this too, but it isn't a termcap flag.OUTPUT CODES option meaning ~ t_AB set background color (ANSI) *t_AB* *'t_AB'* t_AF set foreground color (ANSI) *t_AF* *'t_AF'* t_AL add number of blank lines *t_AL* *'t_AL'* t_al add new blank line *t_al* *'t_al'* t_bc backspace character *t_bc* *'t_bc'* t_cd clear to end of screen *t_cd* *'t_cd'* t_ce clear to end of line *t_ce* *'t_ce'* t_cl clear screen (required!) *t_cl* *'t_cl'* t_cm cursor motion (required!) *t_cm* *'t_cm'* t_Co number of colors *t_Co* *'t_Co'* t_CS if non-empty, cursor relative to scroll region *t_CS* *'t_CS'* t_cs define scrolling region *t_cs* *'t_cs'* t_da if non-empty, lines from above scroll down *t_da* *'t_da'* t_db if non-empty, lines from below scroll up *t_db* *'t_db'* t_DL delete number of lines *t_DL* *'t_DL'* t_dl delete line *t_dl* *'t_dl'* t_fs set window title end (from status line) *t_fs* *'t_fs'* t_ke out of "keypad transmit" mode *t_ke* *'t_ke'* t_ks put terminal in "keypad transmit" mode *t_ks* *'t_ks'* t_le move cursor one char left *t_le* *'t_le'* t_mb blinking mode *t_mb* *'t_mb'* t_md bold mode *t_md* *'t_md'* t_me Normal mode (undoes t_mr, t_mb and t_md) *t_me* *'t_me'* t_mr reverse (invert) mode *t_mr* *'t_mr'* *t_ms* *'t_ms'*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -