Linux Editor
Edit the file to be quick and not broken
What is the current editor? Learn Which? The first thing to consider is what to do with the editor, if you are editing plain text files, no choice, only vim.
Common in Linux system Default editor is: VI vim gedit emacs Nano
Common professional text editors under Windows:
Sublime Text3, notepad++, Notepad2, Emacs, Gvim, UltraEdit, EditPlus
Office, WPS, notepad these 3 desktop offices can also, if you are an OPS or developer, directly discard
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This article describes the common use of artifact vim
To open a file using vim:
#vim file name
Three modes: Command editor last line
Command mode:
Use only shortcut keys
How to enter edit mode: A i o a i o r r
Enter command mode from edit mode: ESC
Cursor positioning:
H J k L corresponds to left upper and lower right ARROW keys respectively
0 or ^ position the cursor to the beginning of the current line
$ position cursor to the end of the current line
Control+command+ around keys (vim within Apple virtual machines only) cursor moves to the beginning and end of the line
Control+windows+ around key or shift+ cursor moves to the beginning and end of the line
GG positioning to top of text
G Navigate to bottom of text
3G Enter third line
DD Delete (cut) The current cursor in the row
Number +DD Delete multiple lines
P Paste
P pastes a row on the line where the current cursor is located
U undo Undo
Ctrl+r rollback
YY copies the current cursor in the row
Digital +yy Copy Multiple lines
D Delete content after the current cursor
d^ Delete the contents before the current cursor
Edit mode Ctrl+u Delete the contents before the current cursor
V Visual Line Mode
Y copy
D Delete
P Paste
= Align the book
Ctrl + V Visual block mode
To add a comment:
Select the first column character that you want to add a comment line-->i--write comment-->esc two times
V Visualization mode
V Cancel Visual mode
Edit mode
Edit Content
Tail line mode
Set Vim's feature finder to replace
Find
/keyword n n
/^d
/txt$
: Set NU Displays line number
: Set Nonu Cancel line number
: The set IC is not case-sensitive when searching
: Set Noic cancel case insensitive
: Set ts=4 setting tab length
: Set sw=4 set tab length for auto indent
: Set SI auto indent
: Set CI
Encryption
: X
Decrypt
: Set key=
Replace
S
: s/world/nice/replaces the current cursor in the row
:%s/world/nice/% means replacing all rows
:%s/world/nice/g replaces all keywords in line
: 3s/world/nice/replaces the specified line
: 3,10s/world/nice/lines 3rd to 10th
: 3,4s/^/#/
:, 8s/hello/hi/ from current line to line 8th
: 5,10 s/.*/#&/5-10 before adding the # character (. * Full line & reference find)
: W Save
: Q exit
: Wq Save Exit
: x Save exit//shortcut key ZZ
: wq! Force Save exit
: r/etc/passwd read into the contents of another file
: W/root/desktop/abc Save As
: SP file name
: VSP file name
Switch between ctrl+w windows
Shift+zz command line mode save exit directly
Make Vim settings permanent:
Mode 1: Write the settings to the end of the VIMRC file and take effect for all accounts
Like what:
#vim/ETC/VIMRC
Set Nu
Set IC
Set ts=4
Set sw=4
Mode 2: Write the settings to the. vimrc file, which is only valid for a user
# VIM/ROOT/.VIMRC
======================================
Compare the differences between two files:
# vimdiff/etc/hosts Hosts1
This article from "crazywing" blog, reproduced please contact the author!
Vim Editor Detailed