documents/dev/Vim-cheat-sheet.md

Vim Cheatsheet

Neovim

Copying and pasting - Hold down the Shift key and select text with the mouse cursor. Text will be copied to the clipboard. This also works for pasting from the clipboard in to vim. This works for vim running in a terminal such as xterm.

Remotes

Server mode without going through ssh

Start the server on one machine

nvim --headless --listen 0.0.0.0:9321

Connect to that session from another machine

nvim --remote-ui --server <addr>:9321

https://github.com/mhinz/neovim-remote

g - prefix for navigating line g0 - char first line gj or g+DownArrow - down one row (same line) gk or g+UpArrow - up one row (same line) gm - jump to middle character of screen line ( and ) - prev/next sentence

Info

g ctrl+g - get word count and other info

Plugins

  • ctrl+j/k - next/ previous ALE errors
  • ctrl+g, j/k - next / previous git changes
  • leader, c, space - toggle comment

FUGITIVE:

  • <leader>s git status
  • <leader>d git diff
  • <leader>dp | dg diff get, diff put
  • <leader>hs stage hunk
  • <leader>hr reset hunk

After doing <leader>s to show git status...

  • For inline split
    • = to show inline split
    • s to stage hunk
    • - to stage/unstage
  • For vertical diffsplit
    • dv to enter diffsplit under cursor
    • of when on file: ctrl-g d
    • then ctrl-g p to "diffput" over to staging file, must write to stage
    • or ctrl-g y to yank / "diffget" HEAD changes