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:
- not shift to the left?
- 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
精彩评论