posts-go/posts/2023-05-03-neovim.md

2.7 KiB

My neovim workflow

nvim-000

All configs are in my dotfiles.

Use both \ and ; as leader key.

Search multiple words:

:/\vword1|word2|word3

Replace word:

:%s/word1/word2/g

Jump basic:

  • gg: first line
  • G: last line
  • 0: first character of line
  • $: last character of line
  • w, b: word forward/backward
  • e, ge: end of word current/before
  • W, B: WORD (word with special char) forward/backward
  • E, gE: end of WORD current/before
  • f{char}, F{char}: find forward/backward character

Jump advance:

  • CTRL-O, CTRL-I: cursor position backward/forward
  • (, ): sentence backward/forward
  • {, }: paragraph backward/forward
  • H: top of screen
  • M: middle of screen
  • L: bottom of screen
  • CTRL-], CTRL-T: jump to tag/jump back from tag

Keymap for plugin (sync with dotfiles):

vim.keymap.set("n", "<leader>f", ":FZF<CR>")
vim.keymap.set("n", "<leader>rg", ":FZFRg<CR>")
vim.keymap.set("n", "<leader>cm", ":FZFCommands<CR>")
vim.keymap.set("n", "<C-n>", ":NvimTreeToggle<CR>")
vim.keymap.set("n", "<leader>n", ":NvimTreeFindFile<CR>")
vim.keymap.set("n", "<leader>tr", ":lua MiniTrailspace.trim()<CR>")
vim.keymap.set("n", "<F2>", ":GoRename<CR>")
vim.keymap.set("n", "<leader>gf", ":GoFillStruct<CR>:w<CR>")
vim.keymap.set("n", "<leader>gat", ":GoAlternate<CR>")
vim.keymap.set("n", "<leader>gt", ":GoTest<CR>")
vim.keymap.set("n", "<leader>gr", ":GoReferrers<CR>")
vim.keymap.set("n", "<leader>gcv", ":GoCoverage<CR>")
vim.keymap.set("n", "<leader>gdd", ":GoDeclsDir<CR>")
  • With nvim-tree/nvim-tree.lua, inside nvim-tree:
    • a: create
    • d: delete
    • r: rename
    • x: cut
    • c: copy
    • p: paste
    • U: toggle hidden
  • With lewis6991/gitsigns.nvim:
    • ]c, [c: next/previous git change
  • With echasnovski/mini.nvim
    • With mini-bracketed
    • With mini-comment
      • gcc: comment/uncomment current line
      • gc: comment/uncomment selected lines
    • With mini-surround
      • sa: add surround
      • sd: delete surround
      • sr: replace surround

Reference