Contents:
Docs & Articles #
Important:
Other:
- Use Vim macros to automate frequent tasks
- Configuring .ideavimrc (archive)
- Everyone Who Tried to Convince Me to use Vim was Wrong (archive)
- Seven habits of effective text editing (archive)
- Vim - precision editing at the speed of thought (Vimeo.com video)
- Vim Adventures (game)
- Vim content by Alvin Alexander (archive)
- Vim Tips for the Intermediate Vim User (archive)
- VimGolf (archive)
Setup #
Installing the Python provider #
Some plugins require the Python provider to be available. This can be checked with the following vim command:
:checkhealth provider
This requires the pynvim Python package.
It’s best if the setup uses virtualenv. On macOS prefer to use pyenv:
brew install pyenv pyenv-virtualenv
This needs the following initialization code in ~/.zshrc:
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Then, install a Python 3 version:
pyenv install 3.10.6
Create a new virtualenv:
pyenv virtualenv 3.10.6 neovim
Activate it temporarily in your shell session:
pyenv activate neovim
Install the required Python package:
pip install pynvim
Then add this to ~/.config/nvim/init.vim:
let g:python3_host_prog=expand('~/.pyenv/versions/neovim/bin/python')
Random tips #
Documentation #
:help:help g:help motion.txt:help spell.txt:help user-manual:help visual.txt
Surround text #
Functionality from vim-surround, which also works in VS Code (with VSCodeVim):
v # Enter visual mode
<visually select> # Use the keyboard to select the section of text
s # Press upper case S
" # Specify what you want to surround the visual selection with
Visual-block mode #
This works like (and implemented with) multi-cursors in other editors (see VS Code (archive)).
Ctrl-vto enter visual-block mode- Select block
I(capital letter) to enter insert mode<Esc>to exit insert mode
Copy & Paste #
Shortcuts:
dis for cut,yis for copy,porPare for paste
Normally one uses the clipboard register to cut, copy and paste, which is *.
So "*y copies to the system clipboard, and "*p pastes from that clipboard.
To activate the system clipboard for copy and pasting with the “unnamed” register, add this to .vimrc:
set clipboard+=unnamed
Fold / Unfold #
zc: foldzo: unfoldzM: fold allzR: unfold all
Go to … #
gd: go to definitiongx: open linkCtrl+O: jump back to last position
Vimdiff #
do: Get changes from other window into the current windowdp: Put the changes from current window into the other window.]c: Jump to the next change.[c: Jump to the previous change.Ctrl W + Ctrl W: Switch to the other split window.
Record macros #
- to record macros:
q<register><commands>q- pressing
qastarts recording in registera - pressing
qagain stops recording
- pressing
- to view recorded macros:
:reg - to play the macro once:
@<register>@aplays the macro in registera
- to repeat the macro execution:
@@
LazyVim setup #
The following tips assume LazyVim.
Shortcuts #
Search for files:
<leader><leader>
Search text in files:
<leader>sg
View list of errors and warnings reported in project:
<leader>xx
Switch to window:
Ctrl-w + h/j/k/l
Close current window:
Ctrl-w + q
Open link at cursor:
gx
Go to definition at cursor:
gd
Go back:
Ctrl-t