yequari.com

Vim Tips

Note: My configuration is a lightly-modified fork of kickstart-nvim , which provides a decent starting point for neovim configs, complete with LSP support and many keybindings. I am not a neovim configuration wizard so I am not 100% clear on which of these keybindings are available by default in neovim.

General Tips

  • vim -p file1 file2 to open multiple files as tabs
  • :qa to quit out of all open buffers
  • :Ex to return to netrw (file explorer)

Terminals

  • :![cmd] to run a [cmd] in the shell, good for quick one-off commands
    • I use this for hugo new a lot when working on my website!
  • :term to open a terminal in current window
  • Use i to enter insert mode and type into the shell
  • <C-\><C-n> to return to normal mode to allow scrolling or switching windows
    • I’ve remapped this to <C-space>

Windows

  • <C-w> prefixes all window commands
  • <C-w> + h,j,k,l to focus window to left, bottom, up, right, respectively
  • <C-w>s to split current window horizontally, equivalent to :split
  • <C-w>v to split current window vertically, equivalent to :vs
  • <C-w>= to equally resize all windows

Registers

  • "c before a command, where c is the register to store the text
  • Use capital letter to append to the register, e.g. "C

Macros

  • Press qc to start recording, where c is the register to store the macro
  • Stop recording with q
  • Replay the macro with @c

Jumps

  • When you jump to a new location (such as using LSP go to definition), <C-o> will jump back to your previous spot
    • This is a stack, similar to undo, so you can jump back several times.
Tags: