1. Display TAB key
You can't see the TAB key in the file. To show it:
: Set list
Now the TAB key is displayed as ^i, and $ is displayed at the end of each line so that you can find out where whitespace characters may be ignored by you.
One drawback to this is that it looks ugly when you have a lot of tabs. If you use a color-based terminal, or use GUI mode, Vim can highlight spaces and tabs.
Use the ' listchars ' option:
: Set listchars=tab:>-,trail:-
The tab is now displayed as ">-" and the extra white space character at the end of the line is displayed as "-". It looks a lot better, doesn't it?
————————————————————————————
2. Let vim display the space at the end of the line
Under Fedora 9 System
Add the following two lines to the/ETC/VIMRC file
Highlight Whitespaceeol ctermbg=red guibg=red
Match Whitespaceeol/\s\+$/
————————————————————————————
3. Vim Search and replace
Search for a range of replacements. If no range is specified, search is replaced only in the current row.
The search is replaced on all lines. The range symbol% represents a search substitution on all rows. :%s/from/to/is the full-text lookup from and replaced with to.
Replaces the search on the specified line. : 1,50s/from/to/means searching and replacing between lines 1th and 50th, including rows 1 and 50. : 45s/from/to/means searching and replacing only on line 45th. The "1,$" line number range and "%" are equivalent.
————————————————————————————
4, VIM multi-line indentation skills
Keywords: vim indent
Press V to enter visual state, select multiple lines, indent or indent with > or <
Automatic indentation is usually used according to the language characteristics: Use = = in the command state for the current line (double-click = two times), or n== (n is natural number) for multiple lines to automatically indent the following n rows from the current line. You can try to indent the code arbitrarily and then use the n== layout, which is equivalent to the normal IDE's code format. Use Gg=g to compose the entire code.
Vim Multi-line Comment
: 20,30 s/^/#/g 20th to 30th line with # comment out.
: 20,30 s/^#//g Uncomment
: 4,10 s/^[^i]\+//Remove blank characters from beginning of line
Use. Represents the current row.
:., s/^/#/g
You can see that the VIM command is for the current line, with a range above it for multiple lines.
: Co 12
Copy the current line to line 12.