2016-10-06 4 views
1

Im on macと私の端末カーソルを垂直バーオプションに設定しました。しかし、vimコマンドモードでは、カーソルは垂直バーですが、hjklを使用して行の最後に移動させることはできません。終了する前に常に停止します。挿入モードで矢印キーを使用してカーソルを行末に移動させる必要があるため、これは特に厄介です。どんな修正もありがたいですコマンドモードの垂直vimカーソル

例:hello worl | d、私が欲しいのはこんにちは世界です|

答えて

2

私はあなたがset virtualedit=onemoreを探していると思います。 :help 'virtualedit'から

A comma separated list of these words: 
    block Allow virtual editing in Visual block mode. 
    insert Allow virtual editing in Insert mode. 
    all  Allow virtual editing in all modes. 
    onemore Allow the cursor to move just past the end of the line 

[...] 

"onemore" is not the same, it will only allow moving the cursor just 
after the last character of the line. This makes some commands more 
consistent. Previously the cursor was always past the end of the line 
if the line was empty. But it is far from Vi compatible. It may also 
break some plugins or Vim scripts. For example because l can move 
the cursor after the last character. Use with care! 

私は何の問題も自分に気づいたことがありませんので、警告にもかかわらず、合理的に安全なようです。

0

iTerm2を使用している場合は、ちょっとしたトリックがあります:あなたのモードに応じて自動的にカーソルを切り替えることができます。 (&t_SI)を

let &t_EI = "\<Esc>]50;CursorShape=0\x7" 
let &t_SI = "\<Esc>]50;CursorShape=1\x7" 

これは入るこれらの文字列を印刷するにはVimを指示:あ​​なたのデフォルトのカーソルをブロックカーソルで、あなただけの挿入モードでの垂直バーをしたい場合、これはうまく動作しますが、私はそれにもかかわらず、それを紹介します(&t_EI)挿入モードを終了します。 iTerm2には、proprietary escape codesの束があり、文字列をカーソルの形を変更する命令として解釈します。

それでは、vimを起動するときに"\<Esc>]50;CursorShape=0\x7"、終了時に"\<Esc>]50;CursorShape=1\x7"を印刷する必要があります。そのためには、autocmds使用することができます。

autocmd BufEnter * execute 'silent !echo -ne "' . &t_EI . '"' 
autocmd VimLeave * execute '!echo -ne "' . &t_SI . '"' 

これは自動的にVimを入力するときのボックスにカーソルの形状を変更し、終了時に垂直バーにそれを復元します。