When a user uses the control sequence, the remote host can control the Tera Term behavior. The Vim procedure for using the control sequence is described below.
Tera Term can support below control sequence changing the cursor shape.
Abbreviation | Sequence | Function |
---|---|---|
DECTCEM | ESC [ ? 25 h | Makes the cursor visible |
ESC [ ? 25 l | Makes the cursor invisible | |
DECSCUSR | ESC SP 0 q | Blink Block |
ESC SP 1 q | Blink Block | |
ESC SP 2 q | Steady Block | |
ESC SP 3 q | Blink Underline | |
ESC SP 4 q | Steady Underline | |
ESC SP 5 q | Blink Vertical line | |
ESC SP 6 q | Steady Vertical line | |
WYSTCURM | ESC [ 33 h | Steady Wyse Cursor |
ESC [ 33 l | Blink Wyse Cursor | |
WYULCURM | ESC [ 34 h | Steady Wyse underline cursor |
ESC [ 34 l | Steady Wyse block cursor | |
(AT&T 610) | ESC [ ? 12 l | Steady Cursor |
ESC [ ? 12 h | Blink Cursor |
The vim cursor can be changed in the insert mode to output above control sequences when a user enters(t_SI) and leaves(t_EI).
For example, when below contents is added in the .vimrc file, the cursor style is underline and blinking in the insert mode. Next, the cursor style is block and blinking outside the insert mode.
let &t_SI .= "\e[3 q" let &t_EI .= "\e[1 q"
NOTICE: If a user uses the control sequence except the DECTCEM, turn on the Cursor control sequence of the Additional Settings dialog(The default value is off).
Basically, the host application can not recognize the difference between the user input and pasting from clipboard. However, when a user uses the Bracketed Paste Mode as the xterm extension, the application can recognize its difference and a user can change the behavior of pasting from clipboard.
The vim configuration is described below. The following will use xterm's bracketed paste mode to make pasting automatically enable paste mode and insert mode. Also works fine in ~/.vimrc file.
if &term =~ "xterm" let &t_ti .= "\e[?2004h" let &t_te .= "\e[?2004l" let &pastetoggle = "\e[201~" function XTermPasteBegin(ret) set paste return a:ret endfunction noremap <special> <expr> <Esc>[200~ XTermPasteBegin("0i") inoremap <special> <expr> <Esc>[200~ XTermPasteBegin("") cnoremap <special> <Esc>[200~ <nop> cnoremap <special> <Esc>[201~ <nop> endif
When a user pastes at the normal mode by using the above configuration, the mode will be automatically changed to the insert mode and do the paste. If this behavior is denied, use the below configuration.
Also, refer to the GNU Screen Notice.
if &term =~ "xterm" let &t_SI .= "\e[?2004h" let &t_EI .= "\e[?2004l" let &pastetoggle = "\e[201~" function XTermPasteBegin(ret) set paste return a:ret endfunction inoremap <special> <expr> <Esc>[200~ XTermPasteBegin("") endif
The bracketed paste mode is the xterm extension feature. When this feature is enabled, the pasted text is bracketed with control sequences so that the program can differentiate the pasted text from typed-in text.
The program will receive: ESC [ 200 ~, followed by the pasted text, followed by ESC [ 201 ~.
Tera Term can support the original sequence to control the IME behavior. For example, A user can switch the IME status of enabling and disabling to use this control sequence.
When below contents is be added in the .vimrc file, the IME status is off after the insert mode exiting. Next, the IME status is on after the insert mode enabling.
let &t_SI .= "\e[<r" let &t_EI .= "\e[<s\e[<0t" let &t_te .= "\e[<0t\e[<s" set timeoutlen=100
When the timeoutlen of the vim is enabled, the vim will wait until either the complete mapping or key sequence has been received. In other words, the timeoutlen is used to describe the time from IME on to off after the ESC key is pressed in the insert mode.
If the timeoutlen is the small value, a trouble may occur that the cursor and function key do not work well.
As an alternative, please use the Delete wait time after ESC key is pushed in insert mode.
When the ESC key is pressed, Tera Term, xterm and other terminal emulator send the ESC(0x1b) key code. Also, when the cursor key and the function key is pushed, Tera Term sends the ESC key code.
Therefore, the host application can not recognize whether the ESC key is pressed.
So, the vim waits for one second when the ESC key code is received to recognize what key is pressed.
As a result, when a user presses the ESC key, the time for the insert mode exiting will be late for 1 second.
This behavior can not be affected by enabling Changing cursor shape on entering and leaving into insert mode and Controlling IME.
Please use the Application Wheel Mode to resolve this problem. When below contents is added in the .vimrc file, the insert mode is quickly exited after the ESC key is pressed.
let &t_SI .= "\e[?7727h" let &t_EI .= "\e[?7727l" inoremap <special> <Esc>O[ <Esc>
When the GNU Screen is used, an application on the screen sends the control sequence and the sequence will be abandoned because the screen can not support the sequence.
if &term == "screen" let &t_SI .= "\eP\e[3 q\e\\" let &t_EI .= "\eP\e[1 q\e\\" else let &t_SI .= "\e[3 q" let &t_EI .= "\e[1 q" endif
Use the above configuration to resolve this problem. When the terminal type is `screen', the vim entry sandwitches in the sequence between the "\eP" and "\e\\".
However, the screen can not work to switch the window because the sequence can not be managed by the screen.