Linux operation and maintenance to develop mind - vi / vim editor

vi / vim editor

vi / vim in Linux is a text editor, vi editor, originally a Unix editor, vi the GNU project will be transplanted into the open source world, they decided to make some of its improvements, because it is no longer in Unix the original vi editor, the developer rename vi improve, also called vim.

vim editing mode

vim editor used three kinds of modes, namely:

  • Command line mode
  • Text input mode
  • Line mode

Users simply type commands and vim to edit the file name you can start the editor, if the file name vim will open up a new section of the buffer zone does not exist to edit, through the existence of the file name, vim will read the entire contents of a buffer District to prepare for editing.
Entering various mode command follows:

  • The default into the command line
  • Press the ikey to enter text input mode
  • Press ESCenter to enter command mode
  • Press into line mode

vim editor Essential Order

  1. Command-line mode can be achieved delete, copy, paste, undo function, commonly used commands are as follows:
Command line mode command
command description
yy Copy the cursor line
nyy Copy n lines
p,P p paste the next line, P pasted on line
is Copy the phrase cursor, does not copy punctuation
in Undo the last operation
dd Delete the entire line
ndd Delete 5 lines, including the current cursor row
x To delete a character
dw To delete a phrase
a A cursor position from the start input
A From the beginning of the end of the line where the cursor input
i From the former character input cursor one position to start
I From the beginning of the line where the cursor is start typing
O The cursor jumps to the beginning of the next line input
O The cursor jumps to the start line of the line input
R Replacement starts cursor position
ctrl+f Scroll down a screen
ctrl+b Turn on a screen
ctrl+d Scroll down half screen
ctrl+u On the turn and a half screen
ctrl+e Scroll down one line
ctrl+y Scroll up one line
n% File location to n%
zz The current line is moved to the center of the screen
zt The current line is moved to the top of the screen
eg The current line is moved to the bottom of the screen
  1. Line mode can be achieved find, replace, save, exit function, commonly used commands are as follows:
Command line mode
command description
: w Storage
: q drop out
: s/x/y The first row of these x y replaced
: s/x/y/g Replace this line all the x y
: wq! Save and exit
: 1.5s / x / y X 1 to the first five rows replaced y
:1,$s/x/y The first to the last row x 1 y replaced
: 1,3,5s / x / y X 1,3,5 line to replace y
: /word Forward lookup front to back, back to find a group by n, N look ahead to the next
: ?word Forward from the backward lookup, to find back a lower press n, N look ahead to the next
: Not set Show Line Numbers

Guess you like

Origin blog.csdn.net/weixin_45181224/article/details/91360926