开发者

vim auto-complete with cursor adjustment

I am relatively new to vim, but so far I am loving it. I am coming from Geany, and the only thing I really miss about it was the ability to type a single quote, and Geany (or one of it's plugins) would insert another single quote and move the cursor between them. The same thing when you typed the cl开发者_C百科osing '>' on a div tag; Geany would add the closing '' tag and re-position the cursor between them. I know this has to be possible with vim, and I sure it exist somewhere but I'm not finding what I'm looking for with google. How do I achieve this?


You can use HTML AutoCloseTag plugin to automatically close the tags.

http://www.vim.org/scripts/script.php?script_id=2591

and to close the braces, quotes etc, you can use AutoClose plugin:

http://www.vim.org/scripts/script.php?script_id=2009


This seems to work OK for me... gives me '', "", (), and {} with cursor in the right place.

imap ' <C-V>'<C-V>'<Left>
imap " <C-V>"<C-V>"<Left>
imap { <C-V>{<C-V>}<Left>
imap ( <C-V>(<C-V>)<Left>

Might have odd sideffects that I haven't thought of though... And I'm sure theres a nicer solution...


I use delimitMate which works for [], {}, () "", '' but I am not sure it works for tags.


try xptemplate. it auto-closes braces, and have much more code snippets (but i don't use html, so just install it and try some to check if it fits your meeds).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜