开发者

How to make vim move cursor a character to theright on insertleave?

Since mac os x's terminal.app does not support many of the vim visual aspects, including the cursor change from block to line when switching to insert mode, I use osascript to a开发者_StackOverflowccopmlisch something similar.

In my .vimrc file I've written:

autocmd InsertEnter * silent !osascript -e 'tell application "Terminal" to set current settings of first window to settings set 11`j
autocmd InsertLeave * silent !osascript -e 'tell application "Terminal" to set current settings of first window to settings set 12`j

where settings set 11 is a set of terminal setting that has a line cursor and settings set 12 is one that has a block cursor.

This actually works quite well but there is one small problem.. On InsertLeave the cursor always gets moved one character to the left, which isn't such a big deal but it can be anoying.

I tried to compensate by putting autocmd InsertLeave h into my .vimrc, but to no avail (it gives me an error).

How should I tell vim to:

  1. not shift to the left?
  2. if the above isn't possible, to compensate by shifting to the right


Before answering the question, I'd recommend you to have a look in MacVim (if you haven't). If you would like (or need) to stick with terminal, maybe another terminal like iTerm will provide more functionality. Anyway, the cursor change between block - bar is not present in iTerm (at least I think so) and your way to solve it was phenomenal, it's bookmarked here now. Thanks!


An easy way to solve it would be adding another autocommand, like you said. But in yours, the pattern and the correct command to execute are missing.

The h is not a command. To execute a normal mode sequence, use the :normal command. This may work correctly:

au InsertLeave * normal! h
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜