Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4712 by yutakapon, Wed Nov 9 12:23:47 2011 UTC revision 4713 by doda, Fri Nov 11 10:34:01 2011 UTC
# Line 3  Line 3 
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>
# Line 57  For example, when below contents is adde Line 55  For example, when below contents is adde
55  </p>  </p>
56    
57  <pre class="macro-example">  <pre class="macro-example">
58  &quot;for screen  let &amp;t_SI .= "\e[3 q"
59  &quot; term xterm-256color in .screenrc  let &amp;t_EI .= "\e[1 q"
 if &amp;term == &quot;xterm-256color&quot;  
     let &amp;t_SI .= &quot;\eP\e[3 q\e\\&quot;  
     let &amp;t_EI .= &quot;\eP\e[1 q\e\\&quot;  
 elseif &amp;term == &quot;xterm&quot;  
     let &amp;t_SI .= &quot;\e[3 q&quot;  
     let &amp;t_EI .= &quot;\e[1 q&quot;  
 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    
# Line 83  The vim configuration is described below Line 73  The vim configuration is described below
73  </p>  </p>
74    
75  <pre class="macro-example">  <pre class="macro-example">
76  if &amp;term =~ &quot;xterm&quot;  if &amp;term =~ "xterm"
77      &quot;for screen      let &amp;t_SI .= "\e[?2004h"
78      &quot; term xterm-256color in .screenrc      let &amp;t_EI .= "\e[?2004l"
79      if &amp;term == &quot;xterm-256color&quot;      let &amp;pastetoggle = "\e[201~"
         let &amp;t_SI = &amp;t_SI . &quot;\eP\e[?2004h\e\\&quot;  
         let &amp;t_EI = &quot;\eP\e[?2004l\e\\&quot; . &amp;t_EI  
         let &amp;pastetoggle = &quot;\e[201~&quot;  
     elseif &amp;term == &quot;xterm&quot;  
         let &amp;t_SI .= &amp;t_SI . &quot;\e[?2004h&quot;  
         let &amp;t_EI .= &quot;\e[?2004l&quot; . &amp;t_EI  
         let &amp;pastetoggle = &quot;\e[201~&quot;  
     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 &lt;special&gt; &lt;expr&gt; &lt;Esc&gt;[200~ XTermPasteBegin(&quot;0i&quot;)      noremap &lt;special&gt; &lt;expr&gt; &lt;Esc&gt;[200~ XTermPasteBegin("0i")
87      imap &lt;special&gt; &lt;expr&gt; &lt;Esc&gt;[200~ XTermPasteBegin(&quot;&quot;)      inoremap &lt;special&gt; &lt;expr&gt; &lt;Esc&gt;[200~ XTermPasteBegin("")
88      cmap &lt;special&gt; &lt;Esc&gt;[200~ &lt;nop&gt;      cnoremap &lt;special&gt; &lt;Esc&gt;[200~ &lt;nop&gt;
89      cmap &lt;special&gt; &lt;Esc&gt;[201~ &lt;nop&gt;      cnoremap &lt;special&gt; &lt;Esc&gt;[201~ &lt;nop&gt;
90  endif  endif
91  </pre>  </pre>
92    
# Line 116  The program will receive: ESC [ 200 ~, f Line 98  The program will receive: ESC [ 200 ~, f
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.
# Line 145  As an alternative, please use the <a hre Line 126  As an alternative, please use the <a hre
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>
# Line 161  let &t_EI .= "\e[?7727l" Line 142  let &t_EI .= "\e[?7727l"
142  inoremap &lt;special&gt; &lt;Esc&gt;O[ &lt;Esc&gt;  inoremap &lt;special&gt; &lt;Esc&gt;O[ &lt;Esc&gt;
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 &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>  </body>
169  </html>  </html>

Legend:
Removed from v.4712  
changed lines
  Added in v.4713

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