Vim: Add closing buckles, brackets, quotation marks etc. automatically? [duplicate] - vim

This question already has answers here:
Vim plugin for 'auto-closed' parenthesis?
(5 answers)
Closed 6 years ago.
This is something what I miss from other editors. I'm looking for a plugin/config which adds closing mark for some characters automatically.
For example, when I type (, it add ) and prompt will be between it. Similarly with {, " etc. This would be very helpful for me. I know I can do it using Vim command, but my goal is do it automatically.

There is a plugin named auto-pairs.vim available in github. See here : https://github.com/jiangmiao/auto-pairs
It can automatically insert closing brackets and quotes and puts prompt in between both.
It is smart and doesn't insert matching brackets for escaped brackets. It works even if you nest different brackets.

Related

How to escape backslashes and forward slashes in VIM find/search? [duplicate]

This question already has answers here:
How does one escape backslashes and forward slashes in VIM find/search?
(6 answers)
Closed 2 years ago.
for example, I want to find and replace, say my original string is "//hello" to "hello".
Actually I'm trying to uncomment lines which I've commented before.
substitution
if your pattern contains slashes /, e.g. //hello you can of course escape them in s/pat/repl/ command. However, better to pick some another delimiter for your s command:
:s#//hello#whatever#g
In this way, the command is easier to read and understand.
Search
Say If you want to search //hello, you can try a backward search with ?, then you don't have to escape the slashes.
Did you try this:
%s/\/\/hello/hello

What Vim command(s) can be used to erase strings in double(or single) quotes and go insert mode? [duplicate]

This question already has answers here:
How to replace text between quotes in vi
(6 answers)
Closed 5 years ago.
I have documents that are full of double-quoted sentences. And using editors, It seems likely comfortable when 'erase strings surrounded by double(or single) quotes and go insert-mode' function embedded. Is there any way to do it using with vim?
Change inside quotes, ci" (or ci' for single-quoted strings)

vim: Marks getting deleted/lost [duplicate]

This question already has answers here:
Make vim keep mark when I delete the line the mark is on
(2 answers)
Closed 6 years ago.
I've tried to find an answer to this on the googles, but been unsuccessful. The problem is this:
In vim I delete a line that contained a mark; so I guess the mark is also deleted. Now I can't jump back to that location any more. I'm coding so there is a lot of line deleting going on. It's a pain having to manually find the place that I set the mark again.
Is there a way around this? I want vim to jump to aprox the same location where the mark used to be. Either the same line number, or the closest guess.
You can try `. which is a position of the last change occurred in the current buffer. Then you can mark it again.

How do I execute command similar to gg=G in Vim without going to the top of the file? [duplicate]

This question already has answers here:
Indenting entire file in Vim without leaving current cursor location
(5 answers)
Closed 8 years ago.
How can I reformat the whole buffer in Vim, the same way as I am doing using gg=G keys, without going the the top (which is caused by the gg)?
You can mark the current position with m<letter> command and then go back with `<letter>.
mzgg=G`z
The referenced duplicate uses more effective variant of this approach using the fact that double backtick goes to the last cursor position so you don't actually need to mark the current position:
gg=G``
Or you can install a plugin for text object of entire buffer (e.g. https://github.com/kana/vim-textobj-entire) and then do
=ae
(or equivalent with another plugin).

Using listchars to show leading whitespace in Vim [duplicate]

This question already has answers here:
Make Vim show ALL white spaces as a character
(23 answers)
Closed 9 years ago.
I use spaces over tabs. In Sublime Text 2, I would have leading spaces show like so:
I have my .vimrc setup to show tabs, line endings, etc. But I'm not sure how to replicate what I have in Sublime. It was handy as I could still see indentation much more easily when just using spaces.
Here's my line for it now:
set listchars=eol:¬,tab:→→,extends:>,precedes:<
The list+listchars combo can show trailing spaces but not leading spaces.
You could try vim-indent-guide.

Resources