Vim auto-complete with cursor customization

Hey guys, I'm relatively new to vim, but still I like it. I come from Geany, and the only thing I really missed was the ability to enter a single quote, and Geany (or one of its plugins) would insert one single quotation mark and move the cursor between them. Same thing when you entered the closing '>' in the div tag; Geany will add a closing tag and move the cursor between them. I know that this is possible with vim, and I'm sure it exists somewhere, but I cannot find what I am looking for from Google. How to achieve this?

+4
source share
5 answers

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

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

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

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

+2
source

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

imap ' <CV>'<CV>'<Left> imap " <CV>"<CV>"<Left> imap { <CV>{<CV>}<Left> imap ( <CV>(<CV>)<Left> 

Perhaps there are strange side effects that I didn’t even think about ... And I'm sure this is the best solution ...

+1
source

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

0
source

I am using the AutoClose plugin mentioned by Jinxed_Coder. I will look at Delimitmate.

I assigned a card when I do not need autocomplete for "({, for example, when using omnicompletion with neocompcache, it will add opening, but when closing manually it will add double." Add this to your .vimrc and read the documentation.

nmap <F2> <Plug>ToggleAutoCloseMappings

0
source

try xptemplate . it automatically closes curly braces and has much more code snippets (but I do not use html, so just install it and try to check if it suits you).

0
source

Source: https://habr.com/ru/post/1338523/


All Articles