2023-05-02 17:42:11 +00:00
|
|
|
# My neovim workflow
|
|
|
|
|
2023-06-10 03:50:39 +00:00
|
|
|
All configs are in [my dotfiles](https://github.com/haunt98/dotfiles).
|
|
|
|
|
|
|
|
Use both `\` and `;` as leader key.
|
|
|
|
|
2023-05-02 17:42:11 +00:00
|
|
|
Search multiple words:
|
|
|
|
|
2023-06-10 03:50:39 +00:00
|
|
|
```vim
|
2023-05-02 17:42:11 +00:00
|
|
|
:/\vword1|word2|word3
|
|
|
|
```
|
2023-06-10 03:50:39 +00:00
|
|
|
|
|
|
|
Replace word:
|
|
|
|
|
|
|
|
```vim
|
|
|
|
:%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
|
|
|
|
|
|
|
|
Jump advance:
|
|
|
|
|
|
|
|
- `CTRL-O`, `CTRL-I`: cursor position backward/forward
|
|
|
|
- : jump forward cursor position
|
|
|
|
- `(`, `)`: 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 golang definition with [fatih/vim-go](https://github.com/fatih/vim-go).
|
|
|
|
|
|
|
|
Keymap for plugin (sync with dotfiles):
|
|
|
|
|
|
|
|
```lua
|
|
|
|
vim.keymap.set("n", "<leader>f", ":FZF<CR>")
|
|
|
|
vim.keymap.set("n", "<leader>rg", ":Rg<CR>")
|
|
|
|
vim.keymap.set("n", "<C-n>", ":NvimTreeToggle<CR>")
|
|
|
|
vim.keymap.set("n", "<leader>n", ":NvimTreeFindFile<CR>")
|
|
|
|
vim.keymap.set("n", "<leader>z", ":ZenMode<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 [echasnovski/mini.nvim mini-comment](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-comment.md)
|
|
|
|
- `gcc`: comment/uncomment current line
|
|
|
|
- `gc`: comment/uncomment selected lines
|
|
|
|
- With [echasnovski/mini.nvim mini-bracketed](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-bracketed.md)
|
|
|
|
- `[b`, `]b`: buffer 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)
|
|
|
|
|
|
|
|
## Reference
|
|
|
|
|
|
|
|
- [neovim Motion](https://neovim.io/doc/user/motion.html)
|
|
|
|
- [neovim Tagsrch](http://neovim.io/doc/user/tagsrch.html)
|