# My neovim workflow ![nvim-000](https://raw.githubusercontent.com/haunt98/posts-images/main/nvim-000.png) All configs are in [my dotfiles](https://github.com/haunt98/dotfiles). Search multiple words: ```vim :/\vword1|word2|word3 ``` Replace word: ```vim :%s/word1/word2/g ``` Delete all lines contain word: ```vim :g/word/d ``` 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 - Support jump to Go definition with [fatih/vim-go](https://github.com/fatih/vim-go). Use both `\` and `;` as leader key: ```lua vim.keymap.set("n", ";", "", { remap = true }) vim.keymap.set("n", "'", "", { remap = true }) ``` Misc keymap: ```lua vim.keymap.set("n", "n", "nzz") vim.keymap.set("n", "N", "Nzz") vim.keymap.set("n", "q", ":q") ``` - `` prefix: prefer global keymap - `` prefix: prefer lsp keymap, for coding of course :D - With [ibhagwan/fzf-lua](https://github.com/ibhagwan/fzf-lua): - `f`: find files - `rg`: grep files - `s`: find lsp symbols - With [nvim-tree/nvim-tree.lua](https://github.com/nvim-tree/nvim-tree.lua), inside nvim-tree: - ``: toggle - `n`: locate file - `a`: create - `d`: delete - `r`: rename - `x`: cut - `c`: copy - `p`: paste - `U`: toggle hidden - With [hrsh7th/nvim-cmp](https://github.com/hrsh7th/nvim-cmp): - ``: trigger completion - With [lewis6991/gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim): - `]c`, `[c`: next/previous git change - With [echasnovski/mini.nvim](https://github.com/echasnovski/mini.nvim) - With mini-bracketed - `[B`, `]B`, `[b`, `]b`: buffer backward/forward - `[D`, `]D`, `[d`, `]d`: diagnostic backward/forward - `[Q`, `]Q`, `[q`, `]q`: quickfix backward/forward - `[T`, `]T`, `[t`, `]t`: tree-sitter backward/forward - Support more languages with [nvim-treesitter/nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) - 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 - With mini-trailspace - `tr`: trim trailing whitespace - With [neovim/nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) - `gd`: go to definition - `k`: hover - ``: rename - `ca`: code action - `gr`: go to references - `f`: format ## References / Thanks - [neovim Motion](https://neovim.io/doc/user/motion.html) - [neovim Tagsrch](http://neovim.io/doc/user/tagsrch.html) - [neovim Lua-guide](https://neovim.io/doc/user/lua-guide.html) - [Vim Tips (Revisited)](https://bluz71.github.io/2021/09/10/vim-tips-revisited.html)