-
Notifications
You must be signed in to change notification settings - Fork 2
Cheat Sheet
- Basic Key Mappings
- Leader Key Mappings
- Markdown Snippets
- Programming Essentials
- Plugins Key Mappings
Notes:
- The pre-built image contains a set of key mappings. You may find the configuration in ./nvim/keys/mappings.vim
- The pre-built image also comes with a set of
<LEADER>
key bindings withwhich-key
plugin. You may find the configuration in ./nvim/keys/which-key.vim - Feel free to modify the key-mapping configuration files inside the container to adjust your needs. They can be found in
./config/nvim/keys
Note: The <LEADER>
key is defined as <SPACE>
by default
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | S |
:w |
Write (Save) current buffer |
Normal | Q |
:q |
Quit the current buffer |
Normal | R |
:source $MYVIMRC |
Reload neovim config |
Insert | jj |
<Esc>:w |
Quit insert mode and save |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Insert | jj |
<Esc>:w |
Quit insert mode and save |
Insert | vv |
<Esc>bv |
Quit insert mode and enter visual mode in the current cursor position |
Normal | i |
i |
Enter insert mode in the current cursor position |
Normal | a |
a |
Move cursor forward by one character and then enter insert mode
|
Normal | A |
A |
Enter insert mode at the end of the current line |
Normal | o |
o |
Open a new line below the current line and enter insert mode
|
Normal | O |
O |
Open a new line above the current line and enter insert mode
|
Insert | <C-o> |
<Esc>o |
Insert a new line below the current line |
Insert | <C-h> |
<C-h> |
Delete previous character in the current cursor position |
Insert | <C-w> |
<C-w> |
Delete previous word in the current cursor position |
Insert | <C-e> |
<C-o>$ |
Move cursor to the end of the current line |
Insert | <C-a> |
<C-o>0 |
Move cursor to the beginning of the current line |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | <S-Up> |
:m-2<CR> |
Move the current line above |
Normal | <S-Down> |
:m+<CR> |
Move the current line below |
Insert | <S-Up> |
<Esc>:m-2<CR> |
Move the current line above |
Insert | <S-Down> |
<Esc>:m+<CR> |
Move the current line below |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | J |
5j |
Move cursor 5 lines downward |
Normal | K |
5k |
Move cursor 5 lines upward |
Normal | L |
w |
Move cursor to the next word |
Normal | H |
b |
Move cursor to the previous word |
Normal | = |
n |
Next result |
Normal | - |
N |
Previous result |
Normal | G |
G |
Move cursor the last line of the file |
Normal | gg |
gg |
Move cursor to the first line of the file |
Normal | w |
w |
Move cursor to the beginning of the word |
Normal | e |
e |
Move cursor to the end of the word |
Normal | f |
f |
Move cursor to the position input character |
Normal | t |
t |
Move cursor the one character prior to the position of the input character |
Normal | 0 |
0 |
Move cursor to the beginning of line |
Normal | $ |
$ |
Move cursor to the end of line |
Normal | % |
% |
Move cursor to the closest end bracket (parentheses) |
Normal |
[NUMBER]G or [NUMBER]gg
|
[NUMBER]G or [[NUMBER]gg]
|
Move the cursor the a specific line |
Normal | <C-e> |
$ |
Move cursor to the end of the current line |
Normal | <C-a> |
0 |
Move cursor to the beginning of the current line |
Visual | <C-e> |
$ |
Move cursor to the end of the current line |
Visual | <C-a> |
0 |
Move cursor to the beginning of the current line |
Insert | <C-e> |
<C-o>$ |
Move cursor to the end of the current line |
Insert | <C-a> |
<C-o>0 |
Move cursor to the beginning of the current line |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | :term |
:term |
Open a terminal in current buffer |
Normal | <LEADER>, |
:tabe<CR>:term<CR> |
Open a terminal in a new tab |
Normal | <C-x> |
:FloatermToggle |
Toggle a floating terminal window |
Terminal | <C-x> |
<C-\><C-n>:FloatermToggle |
Hide the floating terminal window |
Terminal | <Esc> |
<C-\><C-n> |
Set the terminal to normal mode
|
Terminal | i |
i |
Set the terminal to insert mode
|
Terminal | Q |
<C-\><C-N>:q<CR> |
Exit terminal and close the window |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | <C-c> |
"+yy |
Copy content in the current line to the system clipboard |
Normal | <C-c> |
"+y |
Copy content in the selected line/block of lines to the system clipboard |
Normal | <C-v> |
"+p |
Paste content from the system clipboard to vim register |
Alternatives:
- Use mouse to select text and then right click
copy
to copy the text to the system clipboard on the host machine
Notes: Capital Letter
works for all the files in the current buffer at once, whereas Lower Case Letter
only works for each individual file.
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | ma |
ma |
Mark/Unmark the current cursor position as a
|
Normal | 'a |
'a |
Jump to line of mark a
|
Normal | `a | `a | Jump to position (line and column) of mark a
|
Normal | d'a |
d'a |
Delete from current line to line of mark a
|
Normal | c'a |
c'a |
Change text from current line to line of a
|
Normal | y'a |
y'a |
Copy text from current line to line of a
|
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | <Shift>= |
+ |
<Ctr>a |
Normal | <Shift>- |
_ |
<Ctr>x |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Visual | w |
w |
Select the next word |
Visual | b |
b |
Select the previous word |
Visual | iw |
iw |
Select the next word |
Visual | $ |
$ |
Select the all content from the current cursor position to the end of the current line |
Visual | i" |
i" |
Select the string inside "", excluding "" |
Visual | a" |
a" |
Select the string inside "", including "" |
Normal | ggVG |
ggVG |
Select all content |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | "q5yy |
q5yy |
Copy the content in the next 3 lines to register q
|
Normal | "qp |
"qp |
Paste the content from the register q
|
Normal | "Qyy |
"Qyy |
Add the content in the current line to the existing register q
|
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | q<Number or Letter>0<Content>0j |
q<Number or Letter>0<Content>0j |
Start recoding Marco |
Normal | q |
q |
Stop recoding Macro |
Normal | @<Number or Letter> |
@<Number or Letter> |
Play the recorded Macro |
Normal | <Number>@@ |
<Number>@@ |
Play N times of the previous Macro |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Visual | ``\s{old}/{new}` | :s/{old}/{new}/g |
Substitute target text to the new text in the current selected line/block of lines |
Normal | \s{old}/{new} |
:%s/{old}/{new}/g |
Search the target text and substitute with new text |
Normal | cc |
cc |
Substitute the current line with new text |
Visual | c |
c |
Substitute the current line with new text |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | <LEADER>/ |
:call NERDComment(0,"toggle") |
Toggle comment on the current line or selected block |
Visual | <LEADER>/ |
:call NERDComment(0,"toggle") |
Toggle comment on the current line or selected block |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | >> |
>> |
Indent once |
Normal | << |
<< |
Undo indent once |
Insert | <TAB> |
<C-t> |
Indent once |
Insert | <S-TAB> |
<C-d> |
Undo indent once |
Visual | <TAB> |
>gv |
Indent once |
Visual | <S-TAB> |
<gv |
Undo Indent once |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | sc |
:set spell!<CR> |
Spell Check |
Normal | fg |
:r !figlet |
Figlet |
Normal | za |
za |
Fold/Unfold a paragraph |
Normal | <LEADER><CR> |
:nohlsearch |
Toggle highlight search |
Visual | tb |
:Tabularize /<pattern> |
Format a block of text in certain pattern |
Normal | <LEADER>m |
`` | Toggle the mini-map on the right side |
Normal | <LEADER>r |
:RnvimrToggle<CR> |
Toggle Ranger file manager in a popup window |
Normal | <LEADER>T |
:FloatermToggle |
Toggle a terminal in a popup window |
Normal | <LEADER>S |
:Startify |
Jump to the navigation starting page |
Normal | <LEADER>e |
:CocCommand explorer |
Toggle coc file manager |
Normal | <C-n> |
:NERDTreeToggle |
Toggle NerdTree file manager |
Normal | <LEADER>n |
:NERDTreeToggle |
Toggle NerdTree file manager |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | sr |
:set splitright<CR>:vsplit<CR> |
Split window vertically and focus the right window |
Normal | sl |
:nosplitright<CR>:vsplit<CR> |
Split window vertically and focus the left window |
Normal | su |
:set nosplitbelow<CR>:split<CR> |
Split window horizontally and focus the top window |
Normal | sb |
:set splitbelow<CR>:split<CR> |
Split window horizontally and focus the bottom window |
Normal | sh |
<C-w>t<C-w>H |
Change split direction horizontally |
Normal | sv |
<C-w>t<c-w>K |
Change split direction vertically |
Normal | <LEADER>h |
<C-w>h |
Move focus to the left window |
Normal | <LEADER>j |
<C-w>j |
Move focus to the bottom window |
Normal | <LEADER>k |
<C-w>k |
Move focus to the top window |
Normal | <LEADER>l |
<C-w>l |
Move focus to the right window |
Normal | <LEADER><up> |
:res+5<CR> |
Increase the height of the window by 5 |
Normal | <LEADER><down> |
:res-5<CR> |
Decrease the height of the window by 5 |
Normal | <LEADER><right> |
:vertical resize+5 |
Increase the width of the window by 5 |
Normal | <Leader><left> |
:vertical resize-5 |
Decrease the height of the window by 5 |
Normal | <TAB> |
:bnext |
Move to the next buffer |
Normal | <S-TAB> |
:bprevious |
Move to the previous buffer |
Normal | :tabm N |
:tabm N |
Move the tab to a specific spot in the tab order N
|
Normal | <C-i> |
<C-i> |
Go to he next position in the jump list |
Normal | <C-o> |
<C-o> |
Go to the previous position in the jump list |
Normal | <LEADER>= |
:tabnext |
Go the next tab |
Normal | <LEADER>- |
:-tabnext |
Go to the previous tab |
Visual | <LEADER>p |
<Plug>(coc-format-selected) |
Format the selected block of code |
Normal | <LEADER>p |
<Plug>(coc-format-selected) |
Format the selected block of code |
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | / |
/ |
Search word in current buffer |
Normal | ff |
:Leaderf file<CR> |
Search files |
Normal | fs |
:<C-u><C-r>=printf("Leaderf line %s", "") |
Search content in lines |
Normal | fb |
:<C-u><C-r>=printf("Leaderf buffer %s", "") |
Search buffers |
Notes:
- The
<LEADER>
key is defined as<SPACE>
by default - Use
Which-Key
bindings by default - You may modify the key-bindings to adjust your need. The configuration file can be found in
$HOME/.config/keys/which-key.vim
inside the container
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | <LEADER>/ |
<Plug>NERDCommenterToggle |
Toggle Comment |
Normal | <LEADER>e |
:CocCommand explorer |
Explorer |
Normal | <LEADER>f |
:Leaderf File |
Search Files |
Normal | <LEADER>r |
:RnvimrToggle |
Ranger |
Normal | <LEADER>n |
:NERDTreeToggle |
NERDTree |
Normal | <LEADER>S |
:Startify |
Start Screen |
Normal | <LEADER>h |
<C-w>h |
Focus Left Window |
Normal | <LEADER>k |
<C-w>k |
Focus Top Window |
Normal | <LEADER>j |
<C-w>j |
Focus Bottom Window |
Normal | <LEADER>l |
<C-w>l |
Focus Right Window |
Normal | <LEADER>- |
:-tabnext |
Previous Tab |
Normal | <LEADER>= |
:tabnext |
Next Tab |
Normal | <LEADER><CR> |
:nohlsearch |
Toggle Highlight Search |
Normal | <LEADER>b |
- | LeaderfBuffer |
Normal | <LEADER>u |
:UndotreeToggle |
UndoTree |
Normal | <LEADER>T |
:FloatermToggle |
Floaterm |
Normal | <LEADER>m |
- | Minimap |
Normal | <LEADER>G |
:Floaterm lazygit |
Lazygit (Window) |
Normal | <LEADER><Up> |
:res+5<CR> |
Res+5 |
Normal | <LEADER><Down> |
:res-5<CR> |
Res-5 |
Normal | <LEADER><Left> |
:vertical res-5 |
Vertical Resize-5 |
Normal | <LEADER><Right> |
:vertical res+5 |
Vertical Resize+5 |
Normal | <LEADER>, |
:tabe<CR>:term<CR> |
Open a terminal in a new tab |
w
is for Window Operations
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | v |
<C-w>v |
Split Window Vertically |
Normal | h |
<C-w>s |
Split Window Horizontally |
Normal | = |
:vertical res+5 |
Increase current window width by 5 |
Normal | - |
:vertical res-5 |
Decrease current window width by 5 |
a
is for AsyncRun
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | c |
:cclose |
Close the QuickFix window |
Normal | p |
:AsyncRun -raw python % |
Run current python script and populate the result in the QuickFix window |
x
is for Terminal Operations
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | ; |
:FloatermNew |
Terminal |
Normal | d |
:FloatermNew lazydocker |
Lazydocker |
Normal | y |
:FloatermNew ytop |
Ytop |
Normal | b |
:FloatermNew bashtop |
Bashtop |
Normal | r |
:FloatermNew ranger |
Ranger |
Normal | g |
:FloatermNew lazygit |
Lazygit |
c
is for coc
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | c |
:CocList commands |
CocList commands |
Normal | o |
:CocList outline |
CocList outline |
Normal | m |
:CocList marketplace |
CocList marketplace |
Normal | d |
:CocList diagnostics |
CocList diagnostics |
Normal | a |
:<Plug>(coc-codeaction-selected) |
Apply codeAction to the selected region |
Normal | rn |
:<Plug>(coc-rename) |
Rename |
Normal | ac |
:<Plug>(coc-codeaction) |
Apply codeAction to the current buffer |
Normal | qf |
:<Plug>(coc-fix-current) |
Apply AutoFix to problem on the current line |
Normal | e |
:CocList extensions |
Manage extensions |
Normal | k |
:CocPrev |
Apply default action to previous item |
Normal | j |
:CocNext |
Apply default action to next item |
Normal | p |
:CocListResume |
CocList resume |
s
is for General Search (FZF)
Mode | Shortcut | Equivalent | Usage |
---|---|---|---|
Normal | / |
:History |
Search history |
Normal | ; |
:Commands |
Search commands |
Normal | a |
:Ag |
Text Ag |
Normal | b |
:BLines |
Search current buffer |
Normal | B |
:Buffers |
Open buffers |
Normal | c |
:Commits |
Search commits |
Normal | C |
:Bcommits |
Search buffer commits |
Normal | f |
:Files |
Search files |
Normal | g |
:GFiles |
Search git files |
Normal | G |
:GFiles? |
Search modified git files |
Normal | h |
:History |
Search file history |
Normal | H |
:History: |
Search command history |
Normal | l |
:Lines |
Search Lines |
Normal | m |
:Marks |
Search marks |
Normal | M |
:Maps |
Search normal maps |
Normal | p |
:Helptags |
Search help tags |
Normal | P |
:Tags |
Search project tags |
Normal | s |
:Snippets |
Search snippers |
Normal | S |
:Colors |
Search color schemes |
Normal | t |
:Rg |
Text Rg |
Normal | T |
:BTags |
Search buffer tags |
Normal | w |
:Windows |
Search windows |
Normal | y |
:Filetypes |
Search file types |
Normal | z |
:FZF |
Open FZF |
Mode | Shortcut | Usage |
---|---|---|
Insert | ,f |
Go to the next <++> (placeholder) |
Insert | ,w |
Go to the next <++> (placeholder) and automatically creates new line |
Mode | Shortcut | Usage |
---|---|---|
Insert | ,n |
--- |
Insert | ,b |
Bold text |
Insert | ,s |
|
Insert | ,i |
Italic text |
Insert | ,d |
Code block in line |
Insert | ,c |
Block of code |
Insert | ,m |
- [ ] Check mark |
Insert | ,p |
Picture |
Insert | ,a |
Link |
Insert | ,1 |
# H1 |
Insert | ,2 |
## H2 |
Insert | ,3 |
### H3 |
Insert | ,4 |
#### H4 |
Insert | ,l |
-------- |
Coming soon
Surround.vim is all about "surroundings": parentheses, brackets, quotes, XML tags, and more. The plugin provides mappings to easily delete, change and add such surroundings in pairs
Docs: /~https://github.com/tpope/vim-surround
Mode | Shortcut | Example | Usage |
---|---|---|---|
Normal | yss<quote type> |
yss" | Wrap the entire line with "" |
Normal | ysiw<quote type> |
ysiw" | Wrap word with "" |
Visual | S<quote type> |
Selected the text then press [S"] | Wrap selected text with "" |
Normal | ds<quote type> |
ds" | Delete quote "" |
Normal | cs<quote type> |
cs"' | Change quote from "" to '' |
Rnvimr is a NeoVim plugin that allows you to use Ranger in a floating window.
Docs: /~https://github.com/kevinhwang91/rnvimr
Mode | Operator | Usage |
---|---|---|
Normal | <LEADER>r |
Toggle Ranger in a float window |
Normal | <C-t> |
Open file in a new tab |
Normal | <C-v> |
Open file in a vertical split |
Normal | <C-x> |
Open file in a horizontal split |
Normal | <C-f> |
Open FZF |
Normal | M |
Create a new directory |
Normal | :touch <filename> |
Create a new file |
A powerful tool to comment lines
Docs: /~https://github.com/preservim/nerdcommenter
Mode | Shortcut | Usage |
---|---|---|
Visual | <LEADER>/ |
Toggle comment on the current line or selected block |
Visual | <LEADER>cc |
Comment out the current line or selected block |
Visual | <LEADER>cu |
Uncomments the selected line(s). |
Visual | <LEADER>c<SPACE> |
Toggle comment on the current line or selected block |
vim-which-key is vim port of emacs-which-key that displays available keybindings in a popup
Docs: /~https://github.com/liuchengxu/vim-which-key
Mode | Shortcut | Usage |
---|---|---|
Visual | <LEADER> |
Invoke the menu bar |
Normal | <LEADER> |
Invoke the menu bar |
Use (Neo)Vim terminal in the floating/popup window.
Docs: /~https://github.com/voldikss/vim-floaterm
Mode | Shortcut | Usage |
---|---|---|
Normal | <LEADER>T |
Invoke the floating terminal window |
Normal | <C-x> |
Invoke the floating terminal window |
Terminal | X |
Hide the floating terminal window |
Terminal | <C-x> |
Hide the floating terminal window |
Normal | :FloatermNew <Program> |
Open a program in the float terminal window |
Blazing fast minimap for vim, powered by code-minimap written in Rust
Docs: /~https://github.com/wfxr/minimap.vim
Mode | Shortcut | Usage |
---|---|---|
Normal | <LEADER>m |
Toggle the mini-map on the right side |
An efficient fuzzy finder that helps to locate files, buffers, mrus, gtags, etc. on the fly
Docs: /~https://github.com/Yggdroot/LeaderF
Mode | Shortcut | Usage |
---|---|---|
Normal | ff |
Search files |
Normal | fs |
Search content in lines |
Normal | fb |
Search buffers |
The plug-in visualizes undo history and makes it easier to browse and switch between different undo branches
Docs: /~https://github.com/mbbill/undotree
Mode | Shortcut | Usage |
---|---|---|
Normal | <LEADER>u |
Toggle Undo Tree |
The NERDTree is a file system explorer for the Vim editor. Using this plugin, users can visually browse complex directory hierarchies, quickly open files for reading or editing, and perform basic file system operations
Docs: /~https://github.com/preservim/nerdtree
Mode | Shortcut | Usage |
---|---|---|
Normal | <C-n> |
Toggle NERDTree |
Normal | <LEADER>n |
Toggle NERDTree |
Normal | t |
Open the selected file in a new tab |
Normal | s |
Open the selected file in a vertical split window |
Normal | g |
Open the selected file in a horizontal split window |
Normal | m |
Brings up the NERD Tree menu to add file/dir ; delete file/dir
|
Sometimes, it's useful to line up text. Naturally, it's nicer to have the computer do this for you, since aligning things by hand quickly becomes unpleasant. While there are other plugins for aligning text, the ones I've tried are either impossibly difficult to understand and use, or too simplistic to handle complicated tasks. This plugin aims to make the easy things easy and the hard things possible, without providing an unnecessarily obtuse interface. It's still a work in progress, and criticisms are welcome.
Docs: /~https://github.com/godlygeek/tabular
Mode | Shortcut | Usage |
---|---|---|
Visual | tb |
Format a block of text in certain pattern |
Make your Vim/Neovim as smart as VSCode
Docs: /~https://github.com/neoclide/coc.nvim
Check reference @ Leader Key Mappings
A simple terminal UI for git commands, written in Go with the gocui library
Docs: /~https://github.com/jesseduffield/lazygit
Mode | Shortcut | Usage |
---|---|---|
Normal | <LEADER>G |
Open lazygit in a float window |
Normal | <C-g> |
Open lazygit in a new tab |
A plugin that enables you to run shell commands in background and read output in the quickfix window in realtime
Docs: /~https://github.com/skywind3000/asyncrun.vim
Mode | Shortcut | Usage |
---|---|---|
Normal | <C-p> |
Run the current python script and populate the result in the QuickFix window |
Normal | <LEADER>ap |
Run the current python script and populate the result in the QuickFix window |
Normal | <LEADER>ac |
Close the QuickFix window |