Common command of vim in Linux

  

Multi-line indentation In command mode (press Esc key to enter command mode), press “v” enter visual state, use the up and down keys to select the line to be indented, use “> ” Increase indentation, use “<” reduce indentation

replace

# replace the current line first “vivian”for “sky”

:s/vivian/sky/

# Replace all current rows"vivian" for “sky”

:s/vivian/sky/g

# Replace The first line from the beginning of the nth line to the last line in the last line is "vivian" for "ld";sky”

:n,$s/vivian/sky/

# replace the nth line Start with each line in the last line. All “vivian” is “sky”

:n,$s/vivian/sky/g

# Note: n is a number. When n is “.”, it indicates the current line.

# Replace the first “vivian” of each line as “sky”

:%s/vivian/sky/(same as: g/vivian/s//sky/)

# Replace all “vivian” in each line as “sky”

:%s/vivian/sky/g (same as: g/vivian/s//sky/g)

Multi-line indentation

Press v to enter the visual state, select multiple lines, use > or <indent or retract

Copyright © Windows knowledge All Rights Reserved