07 text processing tools and regular expressions

A VIM text editing tool

1. Insert mode

i Insert at the cursor

I start of line

End of line A

a After the cursor

o Next line

O previous line

2. Extended command mode

:R filename read the contents of the file

:W filename save as

:! The command does not exit vim to execute the command directly

: R! Command Read command output result

3. Address delimitation

: Start, end command

2,10 2 to 10 rows

2,+3 Lines 2 to 5

.Current line

$ Last line

.,$-1 Current line to penultimate line

%full text

Edit command

d delete y copy w file and save as r file insert all contents of the specified file at the specified position p paste the next line P paste the previous line

4. Find and replace

/ Can also search

s/search/replace/g replace all, only replace the first # by default 

s# # #

~/.vrmrc Add a configuration file to increase the line number

:Set ai writing code automatic alignment and indentation

:Set noai cancel automatic alignment

:Set pase keep the original format

: set list display tab carriage return and line feed

:set hlsearch highlight

 :syntax on syntax highlighting default

:Set ff=dos/unix is ​​converted to windows linux

: Set cul to add a horizontal line to the line where the cursor is

2 Command mode

ZZ save and exit

ZQ exit without saving

Guess you like

Origin blog.51cto.com/14234935/2606171
Recommended