My Terminal-Only Development Setup (3)
2024-02-11
In this post I’m just listing some (maybe, based on my use habits) useful commands that I find myself Googling all the time. A lot of them are based on third-party plugins and some are defined in my custom config.lua
so it’s definitely not recommended to take the following as your random online reference of VIM commands.
Description | Command | Source (if not VIM default) |
---|---|---|
Select all content | ggVG |
|
Toggle upper/lower case | ~ |
|
Toggle wrap mode | :toggleWrapMode or yow |
wrapping.nvim |
Split vertically or horizontally | | or - |
custom |
Align markdown tables | ctrl [ and ctrl ] |
vim-simple-align , custom |
Shuffle tabs | tab and shift tab |
custom |
Close current buffer1 | space c |
|
Close current window | :q |
|
Open a new empty buffer | space b |
custom |
Save the changes of current buffer | :w or ctrl s |
and custom |
Toggle file explorer | space e or ctrl e |
neo-tree.nvim , custom |
Multi-cursor select | ctrl n |
vim-visual-multi |
Replace all text | :%s/source/target/g |
vim command |
Surround current word with brackets | ysiw) |
nvim-surround |
Surround current sentence with qutes | ys$" |
nvim-surround |
Surround current selection with quotes | S" |
nvim-surround |
Delete the square brackets around cursor | ds] |
nvim-surround |
Delete the HTML tag around cursor | dst |
nvim-surround |
Change the single quotes to double quotes | cs'" |
nvim-surround |
Change the HTML tab around cursor to <h1> |
csth1 |
nvim-surround |
Enter line-wise visual mode | V |
|
Select multiple lines | ma (from), v'a (to) |
|
Delete multiple lines | ma (from), d'a (to) |
|
Select Virtual Environment | vs |
venv-selector.nvim , custom |
LSP telescope diagnostics | space lw |
|
LSP next diagnostic | space lj |
|
LSP prev diagnostic | space lk |
|
LSP code action | space la |
|
Show side-by-side git diff | :DiffViewOpen |
diffview.nvim |
Delete and substitute current character | cl or s |
|
Delete and substitute current word | ciw |
|
Delete and substitute util the end of the line | c$ or C |
|
Delete and substitute current line | cc or S |
|
Search recent files based on file name | space sr |
telescope.nvim |
Search files based on file name | space sf |
telescope.nvim |
Search files based on text | space st |
telescope.nvim |
Search the current word | * |
|
No highlight | :nohl or space h |
|
Jump in or out | ctrl i or ctrl o |
|
Hover information | K |
|
Go to definition | gd |
|
Go to declaration | gD |
|
Format the current JSON file | :%!jq . |
installed jq package in system |
Move the current line down or up | alt j or alt k |
|
Move the current line to line x |
:m x |
|
Indent or dedent the current line | > or < |
|
Jump forward or backward to the first x |
fx or Fx |
|
Delete forward before or including character x |
dtx or dfx |
|
Delete backward after or including character x |
dTx or dFx |
|
Yank forward before or including character x |
ytx or yfx |
|
Yank backward after or including character x |
yTx or yFx |
|
Delete the word | diw |
-
Very different concepts: buffers vs windows. For example, when a vertical split view is turned on, you can shuffle through all opened buffers in both left and right views. Now, in order to quit this split view, you’re gonna close a window by
:q
. In order to close a buffer (can be seen as an opened file) across both views, we needspace
c
. ↩︎