Skip to content

Instantly share code, notes, and snippets.

@sparkingdark
Last active February 22, 2021 13:43
Show Gist options
  • Save sparkingdark/24d5339a0ba4f69ab4f24ddce548b218 to your computer and use it in GitHub Desktop.
Save sparkingdark/24d5339a0ba4f69ab4f24ddce548b218 to your computer and use it in GitHub Desktop.
Here You find the vim cheatsheet containing useful vim commands.
##############################################################################
# VIM CHEATSHEET English Version
# author skywind3000
# https://github.com/skywind3000/awesome-cheatsheets
##############################################################################
# Edited by Debo
##############################################################################
# Cursor movement
##############################################################################
h Move the cursor to the left, same as the <Left> key
j Move the cursor down, same as the <Down> key
k Move the cursor up, same as the <Up> key
l Move the cursor to the right, same as the <Right> key
CTRL-F Next
CTRL-B Previous
CTRL-U move up half screen
CTRL-D move down half screen
0 Jump to the beginning of the line (the number zero, not the letter O), the effect is equivalent to the <Home> key
^ Jump to the first non-blank character from the beginning of the line
$ Jump to the end of the line, the effect is equivalent to the <End> key
gg jump to the first line, the effect is equivalent to CTRL+<Home>
G jump to the last line, the effect is equivalent to CTRL+<End>
nG jump to the nth row, for example 10G is to move to the tenth row
:n jump to the nth line, for example: 10<Enter> is to move to the tenth line
10% move to 10% of the file
15| Move to the 15th column of the current row
w Jump to the beginning of the next word (word: words separated by punctuation or spaces)
W Jump to the beginning of the next word (WORD: words separated by spaces)
e Jump to the end of the next word (word: words separated by punctuation or spaces)
E jump to the end of the next word (WORD: words separated by spaces)
b The head of the previous word (word: words separated by punctuation or spaces)
B The beginning of the previous word (WORD: words separated by spaces)
ge last word ending
) Move forward one sentence (separated by periods)
(Move backward one sentence (period separated)
} Move forward one paragraph (separated by blank lines)
{Move backward one paragraph (separated by blank lines)
<enter> move to the first non-blank character in the next line
+ Move to the first non-blank character in the next line (same as the Enter key)
-Move to the first non-blank character in the previous line
H Move to the top of the screen
M Move to the middle of the screen
L Move to the bottom of the screen
fx jump to the next character x, 2f/ can find the second diagonal bar
Fx jump to the previous character x
tx jump to the next character x
Tx jump to the previous character x
; Skip to the next f/t search result
, Jump to the result of the previous f/t search
<S-Left> Hold down SHIFT and press the left button to move one word to the left
<S-Right> Hold down SHIFT and press the right button, move one word to the right
<S-Up> Hold down SHIFT and press the up button to page up
<S-Down> Hold down SHIFT and press the key to page down
gm move to line
gj Move the cursor down one line (ignore automatic line wrapping)
gk move the cursor up one line (ignore automatic line wrapping)
##############################################################################
# Insert mode: enter and exit
##############################################################################
i Enter insert mode at the cursor
I enter insert mode at the beginning of the line
a Enter insert mode after the cursor
A Enter insert mode at the end of the line
o Insert a new row in the next row and enter insert mode
O Insert a new row in the previous row and enter insert mode
gi enter the position of the last insert mode
<ESC> Exit insert mode
CTRL-[ Exit insert mode (equivalent to ESC, but more convenient)
##############################################################################
# INSERT MODE-After entering insert mode by i, I, a, A, o, O and other commands
##############################################################################
<Up> Move the cursor up
<Down> cursor down
<Left> Move the cursor to the left
<Right> Move the cursor to the right
<S-Left> Hold down SHIFT and press the left button to move one word to the left
<S-Right> Hold down SHIFT and press the right button, move one word to the right
<S-Up> Hold down SHIFT and press the up button to page up
<S-Down> Hold down SHIFT and press the key to page down
<PageUp> page up
<PageDown> Page down
<Delete> delete the character at the cursor
<BS> Backspace delete characters backward
<Home> The cursor jumps to the beginning of the line
<End> The cursor jumps to the end of the line
CTRL-W delete words backward
CTRL-O temporarily exit insert mode, execute a single command and return to insert mode
CTRL-\ CTRL-O temporarily exit insert mode (cursor hold), execute a single command and return to insert mode
CTRL-R 0 Insert the contents of the register (internal clipboard No. 0), the register name can be followed by CTRL-R
CTRL-R "Insert anonymous register content, which is equivalent to p paste in insert mode
CTRL-R = Insert expression calculation result, equal sign followed by expression
CTRL-R: Insert the last command line command
CTRL-R / Insert the last search keyword
CTRL-F auto indent
CTRL-U delete all characters in the current line
CTRL-V {char} insert a non-digit literal
CTRL-V {number} insert ascii/unicode characters represented by three numbers
CTRL-V 065 Insert decimal ascii character (two numbers) 065 is A character
CTRL-V x41 Insert hexadecimal ascii character (three numbers) x41 is A character
CTRL-V o101 Insert octal ascii characters (three numbers) o101 is the A character
CTRL-V u1234 insert hexadecimal unicode characters (four numbers)
CTRL-V U12345678 Insert hexadecimal unicode characters (eight digits)
CTRL-K {ch1} {ch2} insert digraph (see: h digraph), quickly enter Japanese or symbols, etc.
CTRL-D Indent text forward
CTRL-T text indent backward
##############################################################################
# Text Editor
##############################################################################
r replace the current character
R Enter replacement mode, until ESC leaves
s Replace character (delete the character at the cursor and enter the insert mode, the number can be connected before it)
S Replace line (delete the current line and enter the insert mode, the number can be accessed before)
cc rewrite the current line (delete the current line and enter insert mode), same as S
cw rewrite the current word at the beginning of the cursor
ciw rewrite the word under the cursor
caw rewrite the word under the cursor, and include leading and trailing spaces (if any)
c0 is rewritten to the beginning of the line
c^ is rewritten to the beginning of the line (the first non-zero character)
c$ rewrite to the end of the line
C is rewritten to the end of the line (same as c$)
ci" rewrite the content in double quotes
ci' rewrite the content in single quotes
cib rewrite the content in parentheses
cab rewrite the content in the parentheses (including the parentheses themselves)
ci) rewrite the content in parentheses
ci] Rewrite the content in brackets
ciB rewrite the content in braces
caB rewrite the content in the braces (including the braces themselves)
ci} rewrite the content in braces
cit rewrite the content in the xml tag
cis rewrite the current sentence
c2w write down two words instead
ct( rewrite before parentheses
c/apple is rewritten to the first apple after the cursor
x deletes the current character, you can receive a number in front, 3x means delete three characters
X delete characters forward
dd delete the current line
d0 delete to the beginning of the line
d^ Delete to the beginning of the line (the first non-zero character)
d$ delete to the end of the line
D is deleted to the end of the line (same as d$)
dw delete the current word
diw delete the word under the cursor
daw delete the word under the cursor, and include leading and trailing spaces (if any)
di" delete the content in double quotes
di' delete the content in single quotes
dib delete the content in parentheses
di) Delete the content in parentheses
dab delete the content in the parentheses (including the parentheses themselves)
di] Delete the content in brackets
diB delete the content in braces
di} delete the content in the braces
daB delete the content in the braces (including the braces themselves)
dit delete the content in the xml tag
dis delete the current sentence
dip delete the current paragraph (with blank lines before and after it is called a paragraph)
dap delete the current paragraph (including blank lines before and after)
d2w delete the next two words
dt( delete to the parenthesis
d/apple delete to the first apple behind the cursor
dgg delete to the head of the file
dG delete to the end of the file
d) delete the next paragraph
d{ delete the previous paragraph
u Cancel
U Undo the entire operation
CTRL-R undo the last u command
J link has one more row
. Repeat the last operation
~ Replace case
g~iw replace the case of the current word
gUiw convert words to uppercase
guiw convert the current word to lowercase
guu convert all lines to lowercase
gUU convert all lines to uppercase
<< Reduce indentation
>> Increase indentation
== Auto indent
CTRL-A increase number
CTRL-X Decrease number
##############################################################################
# copy and paste
##############################################################################
p paste after the cursor
P Paste before the cursor
v Start tag
y Copy marked content
V starts to mark by line
CTRL-V start column mark
y$ copy the current position to the end of the line
yy copy the current line
Y copy the current line, same as yy
yiw copy current word
3yy Copy the three lines under the cursor
v0 Select the current position to the beginning of the line
v$ select the current position to the end of the line
viw select the current word
vib selects things in parentheses
vi) Select things in parentheses
vi] Select things in brackets
viB selects things in braces
vi} select things in braces
vis select things in the sentence
vip select the current paragraph (with blank lines before and after it is called a paragraph)
vap select the current paragraph (including blank lines before and after)
vab selects things in parentheses (including parentheses themselves)
va) Select the things in the parentheses (including the parentheses themselves)
va] Select the things in the brackets (including the brackets themselves)
vaB selects what is inside the braces (including the braces themselves)
va} Select what is inside the braces (including the braces themselves)
gv reselect the last selected text
:set paste allows paste mode (to avoid automatic indentation affecting the format when pasting)
:set nopaste prohibit paste mode
"?yy copy the current line to the register?, the question mark represents the register name from 0-9
"?d3j delete the three lines under the cursor and put them in the register?, the question mark represents the register name from 0-9
"?p Paste the contents of the register? after the cursor
"?P Paste the contents of the register? before the cursor
:registers display the contents of all registers
:[range]y Copy range, for example: 20,30y is to copy 20 to 30 lines, and :10y is to copy the tenth line
:[range]d delete the range, for example: 20,30d is to delete 20 to 30 lines, and :10d is to delete the tenth line
ddp exchange two lines of content: first delete the current line, copy it to the register, and paste
"_[command] Use [command] to delete content without copying (not polluting registers)
"*[command] Use [command] to copy content to the system clipboard (requires the vim version to have clipboard support)
##############################################################################
# Text object-c, d, v, y and other commands followed by text objects, generally: <range i/a> <type>
##############################################################################
$ To the end of the line
0 to the beginning of the line
^ To the beginning of the line non-blank character
tx cursor position before character x
fx cursor position to character x
iw whole word (not including separator)
aw whole word (including delimiter)
iW the entire WORD (not including the separator)
aW the entire WORD (including the separator)
is the entire sentence (excluding separators)
as the entire sentence (including separators)
ip the entire paragraph (not including blank lines before and after)
ap the entire paragraph (including blank lines before and after)
ib in parentheses
ab inside the parentheses (including the parentheses themselves)
iB inside braces
aB inside the braces (including the braces themselves)
i) In parentheses
a) Inside the parentheses (including the parentheses themselves)
i] inside brackets
a] Inside the brackets (including the brackets themselves)
i) inside braces
a} Inside the braces (including the braces themselves)
i'in single quotes
a'inside single quotation mark (including single quotation mark itself)
i" inside double quotes
a" inside double quotes (including the double quotes themselves)
2i) Inside two parentheses
2a) Inside the two parentheses (including the parentheses)
2f) to the second parenthesis
2t) to before the second parenthesis
##############################################################################
# Find and replace
##############################################################################
/pattern Search pattern from the cursor to the end of the file
?pattern Search pattern from the cursor to the beginning of the file
n Perform the last search in the same direction
N Perform the last search in the opposite direction
* Search forward the word under the cursor
# Search backward for the word under the cursor
:s/p1/p2/g Replace all p1 with p2 in the current line
:%s/p1/p2/g Replace all p1 with p2 in the current file
:%s/p1/p2/gc Replace all p1 with p2 in the current file, and ask you whether to replace it everywhere
:10,20s/p1/p2/g Replace all p1 in rows 10 to 20 with p2
:., ns/p1/p2/g Replace all p1 from current line to n line with p2
:., +10s/p1/p2/g Replace all p1 with p2 in the interval from the current line to the relative current line plus 10 lines
:., $s/p1/p2/g Replace all p1 from the current line to the last line with p2
:%s/1\\2\/3/123/g Replace "1\2/3" with "123" (special characters are marked with backslashes)
:%s/\r//g delete DOS newline ^M
##############################################################################
# VISUAL MODE-Visual mode entered by v, V, CTRL-V
##############################################################################
> Increase indentation
<Decrease indent
d Delete the highlighted text
x Delete the highlighted text
c Rewrite the text, that is, delete the highlighted text and enter the insert mode
s Rewrite the text, that is, delete the highlighted text and enter the insert mode
y Copy text
~ Convert case
o Jump to the other end of the marked area
O Jump to the other end of the marked block
u The marked area is converted to lowercase
U mark area converted to uppercase
g CTRL-G Display the statistics of the selected area
<Esc> Exit visual mode
##############################################################################
# Location jump
##############################################################################
CTRL-O jump to the previous position
CTRL-I jump to the next position
CTRL-^ Jump to alternate file (the previous file in the current window)
% Jump to the match of {} () []
gd jump to the local definition (the definition of the word under the cursor)
gD jump to global definition (the definition of the word under the cursor)
gf open the file whose name is the file name under the cursor
[[ Jump to the previous top-level function (such as C language separated by braces)
]] Jump to the next top-level function (for example, C language is separated by braces)
[m Jump to the previous member function
]m jump to the next member function
[{ Jump to the previous unmatched {
]} Jump to the next unmatched}
[( Jump to the previous unmatched (
)) Jump to the next unmatched)
[c The last difference (when diffing)
]c The next difference (when diffing)
[/ Jump to the beginning of C comment
]/ Jump to the end of C comment
`` Back to the last jumped position
'' Go back to the last jumped position
`. Back to the last edited position
'. Back to the last edited position
##############################################################################
# File operations
##############################################################################
:w save the file
:w <filename> save file by name
:e <filename> open file and edit
:saveas <filename> save as file
:r <filename> Read the file and insert the content after the cursor
:r !dir capture the output of the dir command and insert it after the cursor
:close close the file
:q exit
:q! Force exit
:wa save all files
:cd <path> Switch the current path of Vim
:pwd displays the current path of Vim
:new Open a new window to edit a new file
:enew Create a new file in the current window
:vnew Edit a new file in a new window split left and right
:tabnew Edit the new file in a new tab
##############################################################################
# Open file operation
##############################################################################
:ls Investigation cache list
:bn switch to the next cache
:bp switch to the previous cache
:bd delete cache
:b 1 switch to cache 1
:b abc switch to the cache file name starting with abc
:badd <filename> add file to cache list
:set hidden Set hidden mode (unsaved cache can be switched away or closed)
:set nohidden Turn off hidden mode (unsaved cache cannot be switched away or closed)
n CTRL-^ To switch the cache, enter the numeric cache number first, then press CTRL + 6
##############################################################################
# Window operation
##############################################################################
:sp <filename> Split the window up and down and open the file filename in a new window
:vs <filename> Split the window left and right and open the file filename in a new window
CTRL-W s Split window up and down
CTRL-W v Split window left and right
CTRL-W w Cycle to the next window
CTRL-W W Cycle to the previous window
CTRL-W p jump to the last visited window
CTRL-W c close the current window
CTRL-W o Close other windows
CTRL-W h jump to the left window
CTRL-W j jump to the window below
CTRL-W k jump to the upper window
CTRL-W l Jump to the right window
CTRL-W + Increase the line height of the current window, you can add a number in front
CTRL-W-Decrease the line height of the current window, you can add a number in front
CTRL-W <Reduce the column width of the current window, you can add a number in front
CTRL-W> Increase the column width of the current window, you can add a number in front
CTRL-W = make all windows the same width and height
CTRL-W H Move the current window to the left
CTRL-W J Move the current window to the bottom
CTRL-W K Move the current window to the top
CTRL-W L Move the current window to the far right
CTRL-W x swap window
CTRL-W f Open the file named under the cursor in a new window
CTRL-W gf Open the file named under the cursor in a new tab
CTRL-W R Rotate window
CTRL-W T Move the current window to a new tab
CTRL-W P Jump to the preview window
CTRL-W z Close the preview window
CTRL-W _ Maximize the current window vertically
CTRL-W | Maximize the current window horizontally
##############################################################################
# Bookmark page
##############################################################################
:tabs show all tab pages
:tabe <filename> Open the file filename in a new tab
:tabn next tab page
:tabp previous tab page
:tabc close the current tab page
:tabo close other tabs
:tabn n switch to the nth tab page, for example: tabn 3 switch to the third tab page
:tabm n label move
:tabfirst switch to the first tab page
:tablast switch to the last tab
:tab help opens the help in the tab
:tab drop <file> If the file has been opened by other tabs and windows, skip over, otherwise open a new tab
:tab split opens the file in the current window in a new tab
:tab ball opens all files in the cache with tabs
:set showtabline=? Set to 0 to not display tabs, 1 will be displayed on demand, and 2 will be displayed permanently
ngt switch to the nth tab page, for example, 2gt will switch to the second tab page
gt next tab
gT Previous tab
##############################################################################
# Bookmark
##############################################################################
:marks show all bookmarks
ma save the current position to bookmark a, the lowercase letter of the book signature is in the file, uppercase global
'a jump to the line where bookmark a is located
`a Jump to the location of bookmark a
`. Jump to the last edited line
'A Jump to full text bookmark A
['Jump to the previous bookmark
]'Jump to the next bookmark
'< Jump to the beginning of the last visual mode selection area
'> Jump to the end of the last visual mode selection area
:delm a delete buffer label a
:delm A delete file label A
:delm! Delete all buffer labels (lowercase letters), file labels and digital labels cannot be deleted
:delm AZ delete all file labels (uppercase letters)
:delm 0-9 delete all digital labels (.viminfo)
:delm A-Z0-9 delete all file labels and digital labels
##############################################################################
# Common settings
##############################################################################
:set nocompatible is not compatible with the original vi mode (must be set at the very beginning)
:set bs=? Set BS key mode, modern editor is: set bs=eol,start,indent
:set sw=4 Set the indent width to 4
:set ts=4 Set the tab width to 4
:set noet set not to expand tabs into spaces
:set et set to expand tabs into spaces
:set winaltkeys=no Set the normal capture of ALT keys under GVim
:set nowrap Turn off automatic line wrapping
:set ttimeout Allow terminal key detection to time out (the function key under the terminal is a series of scan codes starting with ESC)
:set ttm=100 Set terminal key detection timeout to 100 milliseconds
:set term=? Set the terminal type, such as the common xterm
:set ignorecase Set the search to ignore case (can be abbreviated as: set ic)
:set noignorecase Set search not to ignore case (can be abbreviated as: set noic)
:set smartcase Smart case, case is ignored by default, unless the search contains uppercase letters
:set list set to display tabs and newlines
:set number Set the display line number, you can use :set nonumber to prohibit the display line number
:set relativenumber Set display relative line number (distance between other lines and current line)
:set paste enter the paste mode (disable indentation and other things that affect formatting when pasting)
:set nopaste end paste mode
:set spell allows spell checking
:set hlsearch Set highlight search
:set ruler always show the cursor position
:set incsearch displays the search results dynamically and incrementally when searching for input
:set insertmode Vim is always in insert mode, use ctrl-o to execute commands temporarily
:set all lists all option settings
:syntax on allows syntax highlighting
:syntax off disable syntax highlighting
##############################################################################
# help information
##############################################################################
:h tutor Getting started documentation
:h quickref quick help
:h index Query all keyboard command definitions in Vim
:h summary helps you better use the built-in help system
:h CTRL-H Query what CTRL-H does in normal mode
:h i_CTRL-H Query what CTRL-H does in insert mode
:h i_<Up> Query what the arrow keys are doing in insert mode
:h pattern.txt regular expression help
:h eval scripting help
:h function-list View VimScript function list
:h windows.txt window help
:h tabpage.txt Tab page usage help
:h +timers show help for +timers feature
:h :! See how to run external commands
:h tips View the common tips document built in Vim
:h set-termcap See how to set the key scan code
:viusage NORMAL mode help
:exusage EX command help
:version displays the current version number and features of Vim
##############################################################################
#External instructions
##############################################################################
:!ls Run external command ls and wait for return
:r !ls Capture the output of the external command ls and insert it after the cursor
:w !sudo tee% sudo save the current file later
:call system('ls') calls the ls command, but does not display the returned content
:!start notepad To start notepad under Windows, you can add silent at the top
:sil !start cmd Open cmd in the current directory under Windows
:%!prog Run a text filter program, such as sorting json format:%!python -m json.tool
##############################################################################
# Quickfix window
##############################################################################
:copen Open the quickfix window (view compilation, grep and other information)
:copen 10 Open the quickfix window and set the height to 10
:cclose close the quickfix window
:cfirst jump to the first error message in quickfix
:clast jump to the last error message in quickfix
:cc [nr] View error [nr]
:cnext jump to the next error message in quickfix
:cprev jump to the previous error message in quickfix
##############################################################################
# Spell Check
##############################################################################
:set spell Turn on spell check
:set nospell turn off spell check
]s the next misspelled word
[s Last misspelled word
zg adds words to the spelling list
zug undo the last word added
z = spelling suggestion
##############################################################################
# Code folding
##############################################################################
za toggle folding
zA recursive switch folding
zc fold the code under the cursor
zC Fold all code under the cursor
zd delete the fold under the cursor
zD delete all folds recursively
zE delete all folds
zf Create code folding
zF Specify the number of rows to create a fold
zi toggle folding
zm all codes folded
zr all codes open one layer
zM Fold all codes, set foldlevel=0, set foldenable
zR Open all codes and set foldlevel to the maximum
zn fold none, reset foldenable and open all codes
zN fold normal, reset foldenable and restore all folds
zo open a layer of code
zO Open all code folding under the cursor
##############################################################################
# Macro recording
##############################################################################
qa starts recording the macro named a
q End recording macro
@a play the macro named a
@@ Play the previous macro
@: Repeat the last ex command (ie colon command)
##############################################################################
# Other commands
##############################################################################
CTRL-X CTRL-F File path completion in insert mode
CTRL-X CTRL-O Insert Omnifunc completion
CTRL-X CTRL-N Keyword completion in insert mode
CTRL-X CTRL-E scroll up in insert mode
CTRL-X CTRL-Y scroll down in insert mode
CTRL-E scroll up
CTRL-Y scroll down
CTRL-G displays the file name being edited, as well as size and location information
g CTRL-G Display file size, number of characters, number of words and lines, also available in visual mode
zz adjust the cursor line to the center of the screen
zt Adjust the cursor line to the top of the screen
zb Adjust the cursor line to the bottom of the screen
ga displays the ascii code or unicode code of the character under the cursor
g8 displays the utf-8 encoding byte order of the character under the cursor
gi returns to the place where it was inserted last time and switches to insert mode
K Query the help of the word under the cursor
ZZ save the file (if there are changes) and close the window
ZQ close the window without saving the file
CTRL-PgUp last tab page, GVim OK, some terminal software needs to set the corresponding keyboard code
CTRL-PgDown Next tab page, GVim OK, some terminal software needs to set the corresponding keyboard code
CTRL-R CTRL-W Insert the word under the cursor in command mode
CTRL-INSERT copy to the system clipboard (GVIM)
SHIFT-INSERT Paste the contents of the system clipboard (GVIM)
:set ff=unix set change to unix
:set ff=dos set change behavior dos
:set ff? View line break settings
:set nohl clear search highlight
:set termcap to see what will be received from the terminal and what commands will be sent to the terminal
:set guicursor= Solve the problem of some strange characters in NeoVim in SecureCRT/PenguiNet
:set t_RS= t_SH= Solve the strange characters in the Vim8.0 terminal function in SecureCRT/PenguiNet
:set fo+=a Enable real-time automatic formatting of text segments
:earlier 15m reverts to the file content 15 minutes ago
:.!date inserts the time in the current window
:%!xxd Start binary editing
:%!xxd -r save binary edit
:r !curl -sL {URL} read the url content and add it after the cursor
:g/^\s*$/d delete blank lines
:g/green/d delete all lines containing green
:v/green/d delete all lines that do not contain green
:g/gladiolli/# Search words and print the results, and add a line number before the results
:g/ab.*cd.*efg/# Search for lines containing ab, cd and efg, print the result and line number
:v/./,/./-j compress empty lines
:Man bash To view man in Vim, first call :runtime! ftplugin/man.vim to activate
/fred\|joe search fred or joe
/\<\d\d\d\d\> Search exactly four numbers
/^\n\{3} Search for three consecutive blank lines
##############################################################################
# Plugin - https://github.com/tpope/vim-commentary
##############################################################################
gcc comment the current line
gc{motion} Annotate the area marked by {motion}, such as gcap annotate the entire paragraph
gci{ comment the content in braces
gc Press gc to annotate the selected area under Visual Mode
:7,17Commentary Comment 7 to 17 lines
##############################################################################
# Plugin - https://github.com/junegunn/vim-easy-align
##############################################################################
:EasyAlign = align with the first matching = as the center
:EasyAlign *= match and align all =
##############################################################################
# Plugin - https://github.com/tpope/vim-unimpaired
##############################################################################
[space insert a blank line up
]space insert a blank line down
[e Replace the current line and the previous line
]e replace the current line and the next line
[x XML encoding
]x XML decoding
[u URL encoding
]u URL decoding
[y C string encoding
]y C string decoding
[q Last quickfix error
]q next quickfix error
[Q First quickfix error
]Q The last quickfix error
[f Switch to the previous file in the same directory
]f switch to the next file in the same directory
[os settings: set spell
]os setting: set nospell
=os setting: set invspell
[on display line number
]on close line number
[ol displays carriage returns and tabs: set list
]ol does not display carriage returns and tabs: set nolist
[b The cache switches to the previous file, namely: bp
]b cache switch to the next file, namely: bn
[B Cache switches to the first file, namely: bfirst
]B cache switch to the last file, namely: blast
##############################################################################
# Plugin - https://github.com/skywind3000/asyncrun.vim
##############################################################################
:AsyncRun ls Run the command ls asynchronously and output the result to quickfix. Use :copen to view
:AsyncRun -raw ls asynchronous run command ls result does not match errorformat
##############################################################################
# Plugin - https://github.com/gaving/vim-textobj-argument
##############################################################################
cia rewrite function parameters
caa rewrite function parameters (including comma separation)
dia delete function parameters
daa delete function parameters (including comma separation)
via select function parameters
vaa select function parameters (including comma separation)
yia copy function parameters
yaa copy function parameters (including comma separation)
##############################################################################
# Internet resources
##############################################################################
The latest version https://github.com/vim/vim
The latest version of Windows https://github.com/vim/vim-win32-installer/releases
Plug-in browsing http://vimawesome.com
reddit https://www.reddit.com/r/vim/
Set the ALT/BS key correctly http://www.skywind.me/blog/archives/2021
Video tutorial http://vimcasts.org/
Chinese help http://vimcdoc.sourceforge.net/doc/help.html
Chinese version entry to proficient https://github.com/wsdjeg/vim-galore-zh_cn
Getting started with five-minute scripting http://www.skywind.me/blog/archives/2193
Script proficiency http://learnvimscriptthehardway.stevelosh.com/
Chinese script help vimcdoc.sourceforge.net/doc/eval.html
Sixteen years of experience http://zzapper.co.uk/vimtips.html
Color scheme http://vimcolors.com/
##############################################################################
# TIPS
##############################################################################
-Never use CTRL-C instead of <ESC>. It has a completely different meaning and can easily interrupt the running background script by mistake
-Many people use CTRL-[ instead of <ESC>, left hand little finger CTRL, right hand little finger [very convenient after being proficient
-If you see strange characters when using Vim 8 embedded terminal in some terminals, use: set t_RS= t_SH= to solve
-When using Vim 8.2+ in some terminals, you will see some strange characters, use: set t_TI= t_TE= to solve
-If you see strange characters when using NeoVim in some terminals, use :set guicursor= to solve
-If you use MS-Terminal to enter Vim/NVim, it will replace the mode setting by default: set t_u7= solve
-Use ciw, ci[, ci", ci( and diw, di[, di", di( commands to quickly rewrite/delete text
-When moving the cursor left and right in the line, use wbe or WBE instead of hl or arrow keys, which will be much faster
-SHIFT is equivalent to moving the accelerator key, wbe moves the cursor very slowly, but WBE moves very fast
-You must be good at summarizing new skills, such as moving to the beginning of a line with a non-empty character, using the 0w command is easier to enter than the ^ command
-Use dip command in blank line to delete all adjacent blank lines, viw can choose continuous blank
-Use >8j >} <ap >ap =i} == when indenting is much more convenient
-In insert mode, when you find a word is wrong, you should use CTRL-W. This is faster than <BackSpace>
-The ydc command can be combined with ft and /X such as dt) and y/end<cr>
-The cdx command will automatically fill the register "1 to" 9, and the y command will automatically fill the "0 register"
-When using the v command to select text, you can use o to turn around to select, which is sometimes useful
-When writing an article, you can write a code block, then select it and execute it:! The python code block will be replaced with the result
-After searching, you often use :nohl to eliminate highlighting. It is used very frequently and you can map to <BackSpace>
-When searching, you can use CTRL-R CTRL-W to insert the word under the cursor, the command mode can also be used
-When mapping keys, noremap should be used by default, and map should be used only when specifically needed
-When you feel that doing something is inefficient, you should stop, uuuu and think about the correct and efficient way to do it
-After copying text with y, press CTRL-R in command mode and press double quote 0 to insert the copied content before
-In some cases, Vim is slow to draw highlights and slow scrolling and refreshing. You can try set re=1 to use the old regular engine
-GVim under Windows can set set rop=type:directx,renmode:5 to enhance the display
##############################################################################
# References
##############################################################################
https://github.com/groenewege/vimrc/blob/master/vim_cheat_sheet.txt
http://blog.g-design.net/post/4789778607/vim-cheat-sheet
http://www.keyxl.com/aaa8263/290/VIM-keyboard-shortcuts.htm
http://jmcpherson.org/editing.html
http://www.fprintf.net/vimCheatSheet.html
http://www.ouyaoxiazai.com/article/24/654.html
http://bbs.it-home.org/thread-80794-1-1.html
http://www.lpfrx.com/wp-content/uploads/2008/09/vi.jpg
http://michael.peopleofhonoronly.com/vim/
https://github.com/hobbestigrou/vimtips-fortune/blob/master/fortunes/vimtips
https://github.com/glts/vim-cottidie/blob/master/autoload/cottidie/tips
# vim: set ts = 4 sw = 4 tw = 0 noet noautoindent fdm = manual:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment