• notice
  • Congratulations on the launch of the Sought Tech site

Vim editor commonly used commands and functions-you can use vimtutor to practice vim commands

Through vimtutor, I have read the common operation commands of vim.There are some notes before, and today I add vimSome supplements on tutor, make a note here:

< span style="white-space:normal;">Vim editor commonly used commands and functions:

[vi editor] visual interface visual interface vim enhanced version; full-screen mode editor
In the command state, use == (double-press=twice), Or use n== for multiple lines (n is a natural number) to automatically indent the following n lines from the current line.
You can try to indent the code arbitrarily and then use n== to typeset, which is equivalent to the code format in the general IDE.Use gg=G to typeset the entire code.
vim +15 file is directly on line 15
vim + file to the last line of the file
vim +/mode file is opened and positioned to the beginning of the line matched by the pattern for the first time
ctrl-g can display the current cursor position
Edit mode [command mode]; input mode last line mode
mode conversion: edit->input
i switch to input mode before the character where the current cursor is located
a input after the current cursor
o Create a new line below the line where the current cursor is located, and switch to input mode
I Switch to input mode at the beginning of the line where the current cursor is located
A Switch to the end of the current line
O At the current line The previous line of the is converted to input mode
Enter->Edit esc; Edit->Last line: Last line->Editing esc sometimes requires 2 consecutive esc (with input last line command)
Last line mode Middle: 10d 10, 20d delete rows.You can also directly use:! Ls   to execute commands.
Close the file: :w! Forcibly save; only root has the right to execute this; :x is equivalent to :wq save and exit.
Exit in edit mode and press ZZ directly to save and exit.
Move the cursor: hjkl.You can add a number;
w moves to the beginning of the next word; e jumps to the end of the current word or the end of the next word
b jumps forward to the beginning of the word, w, Both b and e support adding numbers in front.
Jump within the line: 0 and ^ both indicate jump to the beginning of the line; 0 jump to the absolute beginning of the line; ^ jump to the first non-blank character.$End of line
Jump between lines: how many lines to jump to by adding a number before G, gg jump to the first line, G to the last line
Jump in the last line mode: just press Enter for the line number.
[Flip screen]ctrl+f,b,u,d
[Delete a single character] x    #x delete the following # characters
The d command combined with the jump command can operate multiple places.Such as d plus $/0 can be deleted to the beginning of the end of the line.dw, #d,de,db,dd,#dd,
The last line mode 10,20d deletes 10 to 20 lines..,+5d Delete the 5 lines after the current line.
.The current line $ last line + # the next few lines; $ -1 the last few lines.
[Paste] 
p If the entire line is deleted or copied, it will be pasted below the line where the cursor is located.
  If it is not a whole line, paste it after the character where the cursor is.
P Above the entire line, in front of the cursor.
[Copy] The usage of y is the same as that of d.y$,y0,
[Modify] Delete the content first, then switch to input mode, the c command, the usage is the same as the d command
cc delete and edit; c$ delete the following character and enter the edit.
[Replace] r Replace one character after input.R enters replacement mode.Type is replaced.
[Undo Edit] u Continuous u, and #u undo multiple times.Uppercase U can undo all edits of the current line
[Redo] ctrl+r
[Position forward and backward] Use ctrl-o to jump to the previous watermark position; ctrl-i to jump to the next position (line Switch between)
When the cursor is on a character such as [upper, press% key, it will jump to the corresponding] position.This function mainly finds the symmetrical characters of {[()]}.
[Repeat the previous editing operation]
[Visualization Mode] Select v to select by character, V to select by rectangle, the entire line.Then you can proceed.
[Find] Jump down from /mode n, jump up from N is actually equivalent to /mode and? mode.When the cursor is on a word, using shift+* is equivalent to searching for this word.
Continue to press shift+* (or shift+n) to switch down among these words, and press shift+N to switch up.
[Replace] Same as sed.:30s/he/HE/g  :.s/www/WWW/g    % means the full text.Equivalent to 1,$ represents the full text.Simply use% to represent the full text, without g to replace this line,
add g to replace all, plus gc to find the replacement first, and then which replacements can be operated, :s Only operate on the current line.
If there are many slashes when replacing, you must remember to change the separator
ctrl+V and then press the j key to remove the line break.
vi, enter ":"  + "X"  You can set a password, press lowercase o in the last line to start a new line.
[File switch] Vim can open two files at the same time, in the last line mode: next: prev switch.
You can also open more files: :first :last switches to the first and last file.
:qa exit all files;
[display files in split screen]
ctrl+w,s: split window horizontally; ctrl+w,v: split window vertically.
ctrl+w Up and down arrows switch screens; :aq closes all windows.

You can also use in the last line mode: split and vsplit to split windows
[edit multiple files in windows ] vim -o file is displayed in horizontal division; -O is displayed in vertical division.
[Save part of the current content as another file]
:w /other path can be saved to other files
:add1,add2w /path save part of the content to other files
In command mode, press the v key, then press the arrow keys to select the content, and then enter: enter the mode mode, and then enter the w file path to save the selected line.
[Read another file into the current file]
:r /path/to/file
You can even execute the command at this time: :r !ls Insert the list result into the current file line
>[Open multiple files]
After opening a file, use the :e file path in the last line mode (:e can also use :edit).You can open other files under the current vim, ctrl+6 switches between the last two files.< br>Enter: e and press CTRL-D to list all available commands starting with e.Tab key to select and switch commands.You can also use :open, but the file path after open will not be automatically completed.
At this time, you can use :ls to list all currently opened files, and use b# to edit the corresponding files in the list.:bn—Next file: bp—Previous file
[Interact with shell] Last line mode::! ls executable.
[Advanced topic] Display and cancel line number (vi configuration can be changed, fixed display )
2, set vi to ignore case set ic, that is, ignorerecase is case sensitive set noignorecase 简 set noic
  NOTE: If you want to ignore case for just one search command, use  c  in the phrase :  /ignorec  
3, set automatic indentation.set autoindent, can automatically indent when line breaks.The abbreviation set ai is opposite to set noai
4, do not want the content to be highlighted: set nohlsearch is opposite to set hlsearch is highlighted by default set hls
5, syntax highlighting: :syntax off :syntax on is off and on
6, set incsearch can be set to display the results while typing.简 set is
7,set nocp This command specifies to make VIM work in incompatible mode.

8,set ru  Display the status bar of VIM at the bottom right corner of the screen, including row number, column number, reading volume< br>9,set backspace=indent,eol,start
    set backspace=start can delete the original content before continuing
    set backspace=eol can delete the end of the previous line Press Enter to connect the upper and lower lines.
    set backspace=indent In Insert mode, press Backspace to delete the indentation at the beginning of the line.
10,set whichwrap=b,s,,[,] default In VIM, when the cursor moves to the leftmost side of a line, continue to press the left button.The cursor cannot return to the rightmost side of the previous line.You can change it by setting whichwrap.
11,set encoding=cp936 Set the current character encoding to Simplified Chinese< br>12, set lbr does not break lines in the middle of a word.
[vi edit configuration file] modify /etc/vimrc to enable automatic line number addition
[vim illegal exit] to generate.swp file.You can use the vim -r file to open and restore the edited file
if id user1 &> /dev/null.&> There can be no spaces in between.
Use !vim to open the file opened last time
[Auto-Complete Function] When editing the code in vim, ctrl+x and then ctrl+o can prompt the PHP function.
Finally remember:!!!!!!! vimtutor can help learn vim!!!!!!!

----Other shortcut keys
s Delete the character at the cursor and enter insert mode
    View the line number of the current line
:=                View the total number of lines
ctrl+g            Display the file name, the current line number, the total number of lines in the file and the percentage of the file location

Finally: vim What is the reason why the editor does not respond no matter what you press?

At this time you accidentally press CTRL+S, the result is No matter what vim is pressed, there is no response.It's like a crash, which is really maddening.

Reason:CTRL+S Means to stop output to the terminal, at this time press CTRL+Q to resume.

     View the total number of lines
ctrl+g            Display the file name, the current line number, the total number of lines in the file, and the percentage of the file location

Finally: What is the reason why the vim editor does not respond no matter what you press?

At this time you accidentally press CTRL+S, the result is No matter what vim is pressed, there is no response.It's like a crash, which is really maddening.

Reason:CTRL+S Means to stop output to the terminal, at this time press CTRL+Q to resume.

     View the total number of lines
ctrl+g            Display the file name, the current line number, the total number of lines in the file, and the percentage of the file location

Finally: What is the reason why the vim editor does not respond no matter what you press?

At this time you accidentally press CTRL+S, the result is No matter what vim is pressed, there is no response.It's like a crash, which is really maddening.

Reason:CTRL+S Means to stop output to the terminal, at this time press CTRL+Q to resume.

span style="white-space:normal;">Finally: What is the reason why the vim editor does not respond no matter what you press?

At this time you accidentally press CTRL+S, the result is No matter what vim is pressed, there is no response.It's like a crash, which is really maddening.

Reason:CTRL+S Means to stop output to the terminal, at this time press CTRL+Q to resume.

span style="white-space:normal;">Finally: What is the reason why the vim editor does not respond no matter what you press?

At this time you accidentally press CTRL+S, the result is No matter what vim is pressed, there is no response.It's like a crash, which is really maddening.

Reason:CTRL+S Means to stop output to the terminal, at this time press CTRL+Q to resume.

/span>CTRL+S means stop outputting to the terminal, at this time press CTRL+Q to resume.

/span>CTRL+S means stop outputting to the terminal, at this time press CTRL+Q to resume.

Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+