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.
Related
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
This question already has answers here:
Remove all arbitary spaces before a line in Vim
(9 answers)
Closed 5 years ago.
I'm new to the vim editor.
How can I adjust all lines to the left? I have many lines which are indented and I want to arrange them so they all abut the left side of the file (no spacing at the start of the lines).
Select all line in visual mode and then type :left . Hope this helped.
keerthan
The simple key sequence :%left will do the trick, it basically applies the left command to all lines in the file.
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.
This question already has answers here:
How can you automatically remove trailing whitespace in vim
(14 answers)
Closed 9 years ago.
I have:
int x = 1;______
(underscores means spaces)
and I would like to get:
int x = 1;
My naive solution is $bld$, is there a quickest way?
In Emacs I use M-\ (delete-horizontal-space)
For the current line:
:s/\s\+$
For all lines:
:%s/\s\+$
The substitution text can be omitted if blank, so we don't need to write s/\s\+$//.
I do this with a search and replace mapping:
map <leader>W :%s/\s\+$//<CR>:let #/=''<CR>
:%s/\s\+$// deletes all trailing white space and then :let #/='' clears the search register.
:%s/\s\+$//
What it does is it searches for white spaces at the end of the line and replace them by nothing.
Source: http://vim.wikia.com/wiki/Remove_unwanted_spaces
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Unwrap text in vim
How to convert hard wrap into soft wrap in a text file, using vim or (if simpler) some other standard GNU/Linux tool? And this while preserving paragraphs as such. It would be easy to remove all line breaks, but not serviceable.
By hard wrap I mean a document where each line ends at most at (for example) column 80.
I noticed that the program aquamacs has a function to do this, but I don't know what its output looks like, and it is Mac OS X only.
You can do this:
:%norm vipJ
It will unwrap all the paragraphs in you text. However, if you want to do it manually, simply do ipJ inside visual mode on each paragraph you want to unwrap.
I also found another way to achieve this
:g/^\s*\n.*\S$/+norm vipJ
which means:
:g "Execute command when pattern matches
Pattern:
^\s*\n "A line with only spaces or tabs (or none)
\n.*\S$ "A line with anything but ending with a non-space character
Command:
+norm vipJ "Join the lines in the paragraph
Please note that you'll need an empty line before the first paragraph too.