| 3 |
<html> |
<html> |
| 4 |
<head> |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| 6 |
<title>Tips on vim</title> |
<title>Vim Control Sequence Example</title> |
| 7 |
<meta http-equiv="Content-Style-Type" content="text/css"> |
<meta http-equiv="Content-Style-Type" content="text/css"> |
| 8 |
<link rel="stylesheet" href="../../style.css" type="text/css"> |
<link rel="stylesheet" href="../../style.css" type="text/css"> |
| 9 |
</head> |
</head> |
| 10 |
<body> |
<body> |
| 11 |
|
|
| 12 |
<h1>Tips on vim</h1> |
<h1>Vim Control Sequence Examples</h1> |
|
<h1>VIM Control Sequence Examples</h1> |
|
| 13 |
<p> |
<p> |
| 14 |
When a user uses the control sequence, the remote host can control the Tera Term behavior. |
When a user uses the control sequence, the remote host can control the Tera Term behavior. |
| 15 |
The VIM procedure for using the control sequence is described below. |
The Vim procedure for using the control sequence is described below. |
| 16 |
</p> |
</p> |
| 17 |
|
|
| 18 |
<h2><a name="CursorStyle">Changing cursor shape on entering and leaving into insert mode</a></h2> |
<h2><a name="CursorStyle">Changing cursor shape on entering and leaving into insert mode</a></h2> |
|
|
|
| 19 |
<p> |
<p> |
| 20 |
Tera Term can support below control sequence changing the cursor shape. |
Tera Term can support below control sequence changing the cursor shape. |
| 21 |
</p> |
</p> |
| 55 |
</p> |
</p> |
| 56 |
|
|
| 57 |
<pre class="macro-example"> |
<pre class="macro-example"> |
| 58 |
"for screen |
let &t_SI .= "\e[3 q" |
| 59 |
" term xterm-256color in .screenrc |
let &t_EI .= "\e[1 q" |
|
if &term == "xterm-256color" |
|
|
let &t_SI .= "\eP\e[3 q\e\\" |
|
|
let &t_EI .= "\eP\e[1 q\e\\" |
|
|
elseif &term == "xterm" |
|
|
let &t_SI .= "\e[3 q" |
|
|
let &t_EI .= "\e[1 q" |
|
|
endif |
|
| 60 |
</pre> |
</pre> |
| 61 |
|
|
| 62 |
<p>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). |
<p>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).</p> |
| 63 |
</p> |
|
| 64 |
|
|
|
<h2><a name="Bracketed">Bracketed Paste Mode</a></h2> |
|
| 65 |
<h2><a name="Bracketed">Auto indent can be disabled on pasting from clipboard</a></h2> |
<h2><a name="Bracketed">Auto indent can be disabled on pasting from clipboard</a></h2> |
| 66 |
<p> |
<p> |
| 67 |
Basically, the host application can not recognize the difference between the user input and pasting from clipboard. |
Basically, the host application can not recognize the difference between the user input and pasting from clipboard. |
| 68 |
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. |
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. |
| 69 |
</p> |
</p> |
| 70 |
|
|
| 73 |
</p> |
</p> |
| 74 |
|
|
| 75 |
<pre class="macro-example"> |
<pre class="macro-example"> |
| 76 |
if &term =~ "xterm" |
if &term =~ "xterm" |
| 77 |
"for screen |
let &t_SI .= "\e[?2004h" |
| 78 |
" term xterm-256color in .screenrc |
let &t_EI .= "\e[?2004l" |
| 79 |
if &term == "xterm-256color" |
let &pastetoggle = "\e[201~" |
|
let &t_SI = &t_SI . "\eP\e[?2004h\e\\" |
|
|
let &t_EI = "\eP\e[?2004l\e\\" . &t_EI |
|
|
let &pastetoggle = "\e[201~" |
|
|
elseif &term == "xterm" |
|
|
let &t_SI .= &t_SI . "\e[?2004h" |
|
|
let &t_EI .= "\e[?2004l" . &t_EI |
|
|
let &pastetoggle = "\e[201~" |
|
|
endif |
|
| 80 |
|
|
| 81 |
function XTermPasteBegin(ret) |
function XTermPasteBegin(ret) |
| 82 |
set paste |
set paste |
| 83 |
return a:ret |
return a:ret |
| 84 |
endfunction |
endfunction |
| 85 |
|
|
| 86 |
map <special> <expr> <Esc>[200~ XTermPasteBegin("0i") |
noremap <special> <expr> <Esc>[200~ XTermPasteBegin("0i") |
| 87 |
imap <special> <expr> <Esc>[200~ XTermPasteBegin("") |
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin("") |
| 88 |
cmap <special> <Esc>[200~ <nop> |
cnoremap <special> <Esc>[200~ <nop> |
| 89 |
cmap <special> <Esc>[201~ <nop> |
cnoremap <special> <Esc>[201~ <nop> |
| 90 |
endif |
endif |
| 91 |
</pre> |
</pre> |
| 92 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
<h2><a name="IMEcontrol">Controlling IME</a></h2> |
<h2><a name="IMEcontrol">Controlling IME</a></h2> |
|
|
|
| 101 |
<p> |
<p> |
| 102 |
Tera Term can support the original sequence to control the IME behavior. |
Tera Term can support the original sequence to control the IME behavior. |
| 103 |
For example, A user can switch the IME status of enabling and disabling to use this control sequence. |
For example, A user can switch the IME status of enabling and disabling to use this control sequence. |
| 126 |
<p> |
<p> |
| 127 |
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. |
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. |
| 128 |
Therefore, the host application can not recognize whether the ESC key is pressed. <br> |
Therefore, the host application can not recognize whether the ESC key is pressed. <br> |
| 129 |
So, the vim waits for one second when the ESC key code is received to recognize what key is pressed. |
So, the vim waits for one second when the ESC key code is received to recognize what key is pressed. |
| 130 |
As a result, when a user presses the ESC key, the time for the insert mode exiting will be late for 1 second. |
As a result, when a user presses the ESC key, the time for the insert mode exiting will be late for 1 second. |
| 131 |
This behavior can not be affected by enabling <a href="#CursorStyle">Changing cursor shape on entering and leaving into insert mode</a> and <a href="#IMEcontrol">Controlling IME</a>. |
This behavior can not be affected by enabling <a href="#CursorStyle">Changing cursor shape on entering and leaving into insert mode</a> and <a href="#IMEcontrol">Controlling IME</a>. |
| 132 |
</p> |
</p> |
| 142 |
inoremap <special> <Esc>O[ <Esc> |
inoremap <special> <Esc>O[ <Esc> |
| 143 |
</pre> |
</pre> |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
<!-- |
| 147 |
|
<h2><a name="withScreen">GNU Screenとの併用時の注意点</a></h2> |
| 148 |
|
<p> |
| 149 |
|
GNU Screenを使用している場合、screen内部で動かしているアプリケーションが制御シーケンスを送っても、そのシーケンスにscreenが対応していない場合はTera Term側へ送らずに捨ててしまい期待通りに動きません。その場合、 |
| 150 |
|
</p> |
| 151 |
|
|
| 152 |
|
<pre class="macro-example"> |
| 153 |
|
if &term == "screen" |
| 154 |
|
let &t_SI .= "\eP\e[3 q\e\\" |
| 155 |
|
let &t_EI .= "\eP\e[1 q\e\\" |
| 156 |
|
else |
| 157 |
|
let &t_SI .= "\e[3 q" |
| 158 |
|
let &t_EI .= "\e[1 q" |
| 159 |
|
endif |
| 160 |
|
</pre> |
| 161 |
|
|
| 162 |
|
<p> |
| 163 |
|
というように、端末タイプが screen の時は t_SI, t_EI, t_ti, t_te に設定するシーケンスを "\eP" と "\e\\" で挟むとTera Termに制御シーケンスが届くようになります。<br> |
| 164 |
|
ただし、この方法を使って制御シーケンスがscreenを抜けるようにしても送ったシーケンスの状態はscreenの管理外になるので、screenのウィンドウを切り替えた時等に期待通りに動かない場合がありますので注意してください。 |
| 165 |
|
</p> |
| 166 |
|
--> |
| 167 |
|
|
| 168 |
</body> |
</body> |
| 169 |
</html> |
</html> |