Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/doc/en/html/usage/tips/vim.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4713 - (show annotations) (download) (as text)
Fri Nov 11 10:34:01 2011 UTC (18 months, 1 week ago) by doda
File MIME type: text/html
File size: 7263 byte(s)
ドキュメント修正。
・screen 内かの判断基準として TERM=xterm-256color を使うのは不適切なので、標準である screen に変更
・DSC & ST で囲むと効果があるのは特定のシーケンスに限るわけではない事、および設定する事による副作用が考えられる事から、vim に関する注意点を独立させた
・元の例にあったバグや修正すべき点を修正
・その他こまごまとした修正
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6 <title>Vim Control Sequence Example</title>
7 <meta http-equiv="Content-Style-Type" content="text/css">
8 <link rel="stylesheet" href="../../style.css" type="text/css">
9 </head>
10 <body>
11
12 <h1>Vim Control Sequence Examples</h1>
13 <p>
14 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.
16 </p>
17
18 <h2><a name="CursorStyle">Changing cursor shape on entering and leaving into insert mode</a></h2>
19 <p>
20 Tera Term can support below control sequence changing the cursor shape.
21 </p>
22
23 <table border="1">
24 <tr> <th>Abbreviation</th> <th>Sequence</th> <th>Function</th> </tr>
25
26 <tr> <td rowspan="2">DECTCEM</td>
27 <td>ESC [ ? 25 h</td> <td>Makes the cursor visible</td> </tr>
28 <tr> <td>ESC [ ? 25 l</td> <td>Makes the cursor invisible</td> </tr>
29
30 <tr> <td rowspan="7">DECSCUSR</td>
31 <td>ESC SP 0 q</td> <td>Blink Block</td> </tr>
32 <tr> <td>ESC SP 1 q</td> <td>Blink Block</td> </tr>
33 <tr> <td>ESC SP 2 q</td> <td>Steady Block</td> </tr>
34 <tr> <td>ESC SP 3 q</td> <td>Blink Underline</td> </tr>
35 <tr> <td>ESC SP 4 q</td> <td>Steady Underline</td> </tr>
36 <tr> <td>ESC SP 5 q</td> <td>Blink Vertical line</td> </tr>
37 <tr> <td>ESC SP 6 q</td> <td>Steady Vertical line</td> </tr>
38
39 <tr> <td rowspan="2">WYSTCURM</td>
40 <td>ESC [ 33 h</td> <td>Steady Wyse Cursor</td> </tr>
41 <tr> <td>ESC [ 33 l</td> <td>Blink Wyse Cursor</td> </tr>
42
43 <tr> <td rowspan="2">WYULCURM</td>
44 <td>ESC [ 34 h</td> <td>Steady Wyse underline cursor</td> </tr>
45 <tr> <td>ESC [ 34 l</td> <td>Steady Wyse block cursor</td> </tr>
46
47 <tr> <td rowspan="2"> (AT&amp;T 610) </td>
48 <td>ESC [ ? 12 l</td> <td>Steady Cursor</td> </tr>
49 <tr> <td>ESC [ ? 12 h</td> <td>Blink Cursor</td> </tr>
50 </table>
51
52 <p>
53 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). <br>
54 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.
55 </p>
56
57 <pre class="macro-example">
58 let &amp;t_SI .= "\e[3 q"
59 let &amp;t_EI .= "\e[1 q"
60 </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>
63
64
65 <h2><a name="Bracketed">Auto indent can be disabled on pasting from clipboard</a></h2>
66 <p>
67 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.
69 </p>
70
71 <p>
72 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.
73 </p>
74
75 <pre class="macro-example">
76 if &amp;term =~ "xterm"
77 let &amp;t_SI .= "\e[?2004h"
78 let &amp;t_EI .= "\e[?2004l"
79 let &amp;pastetoggle = "\e[201~"
80
81 function XTermPasteBegin(ret)
82 set paste
83 return a:ret
84 endfunction
85
86 noremap &lt;special&gt; &lt;expr&gt; &lt;Esc&gt;[200~ XTermPasteBegin("0i")
87 inoremap &lt;special&gt; &lt;expr&gt; &lt;Esc&gt;[200~ XTermPasteBegin("")
88 cnoremap &lt;special&gt; &lt;Esc&gt;[200~ &lt;nop&gt;
89 cnoremap &lt;special&gt; &lt;Esc&gt;[201~ &lt;nop&gt;
90 endif
91 </pre>
92
93 <h4>About Bracketed Paste mode</h4>
94 <p>
95 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.<br>
96 The program will receive: ESC [ 200 ~, followed by the pasted text, followed by ESC [ 201 ~.
97 </p>
98
99
100 <h2><a name="IMEcontrol">Controlling IME</a></h2>
101 <p>
102 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.
104 </p>
105
106 <p>
107 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.
108 </p>
109
110 <pre class="macro-example">
111 let &t_SI .= "\e[&lt;r"
112 let &t_EI .= "\e[&lt;s\e[&lt;0t"
113 let &t_te .= "\e[&lt;0t\e[&lt;s"
114
115 set timeoutlen=100
116 </pre>
117
118 <p>
119 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. <br>
120 If the timeoutlen is the small value, a trouble may occur that the cursor and function key do not work well. <br>
121 As an alternative, please use the <a href="#AppESC">Delete wait time after ESC key is pushed in insert mode</a>.
122 </p>
123
124
125 <h2><a name="AppESC">Delete wait time after ESC key is pushed in insert mode</a></h2>
126 <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.
128 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.
130 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>.
132 </p>
133
134 <p>
135 Please use the Application Wheel Mode to resolve this problem.
136 When below contents is added in the .vimrc file, the insert mode is quickly exited after the ESC key is pressed.
137 </p>
138
139 <pre class="macro-example">
140 let &t_SI .= "\e[?7727h"
141 let &t_EI .= "\e[?7727l"
142 inoremap &lt;special&gt; &lt;Esc&gt;O[ &lt;Esc&gt;
143 </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 &amp;term == "screen"
154 let &amp;t_SI .= "\eP\e[3 q\e\\"
155 let &amp;t_EI .= "\eP\e[1 q\e\\"
156 else
157 let &amp;t_SI .= "\e[3 q"
158 let &amp;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>
169 </html>

SourceForge.JP is a Japanese version of SourceForge.net. For developments that are not related to Japan, we recommend you to use SourceForge.net.