# aliquote

## < a quantity that can be divided into another a whole number of time />

Here are the current Neovim mappings I came to feel comfortable with over time. This is by no means a reference card, and yes I do use the arrow keys for navigating into my buffers. It depends on motion range, though. Another key idea is that I use Tmux everyday and I like to have an unified set of mappings, beside the leader/prefix key. See my blog posts for how I started to use Vim and Neovim.

Note that I only have 10 plugins in my start and opt directories, in addition to part of mini.nvim that I adapted to suit my needs better: (This may change in the future but usually I tend to remove plugins rather than add new ones.1 )

• [opt] Comment.nvim, nvim-lspconfig, null-ls.nvim, nvim-parinfer, vim-test, vimtex;
• [start] nvim-treesitter, packer.nvim, plenary.nvim, telescope.nvim

I prefer a minimalist setup these days, and I tend to rely on hand-on solutions for tasks I carry over and over. Many of those custom settings come from briliant Vimers who are acknowledged in my config files. Note that some of those mappings may override existing ones, whether they are somewhat redundant (e.g. s and c) or because I don’t use them at all (e.g., some of the Ctrl, g or z combinations).

My leader is “,"2 and I do not define specific mappings for the localleader in my main config files. It looks like I always misunderstoof the role of localleader, and I decided to book it for my after/ftplugin custom settings.

 Mapping Mode Command Role c : Go to start of line c : Go to end of line - n :Ex Show explorer ,l n Alternate buffer ,! n :10sp +te Popup terminal ,. n :lcd %:p:h Set local current directory ,x n :bp bd! # Kill current buffer ,X n Only() Keep only current buffer (custom) ,E n :tabe =expand("%:p:h") . "/" Open file in new tab from current directory ,e n :e =expand("%:p:h") . "/" Open file from current directory n :tabprev Previous tab n :tabnext Next tab n :tabnext Next tab , n :$tabnew New tab , n C-wT Move split to new tab J n mzJz Join lines (cursor stationary) < v v >gv Fix block indentation (forward) n quickfix_toggle() Close quickfix window (custom) [Q n :cfirst Go to first quickfix item ]Q n :clast Go to last quickfix item n :vertical resize -4 Resize split (left) n :resize -4 Resize split (down) n :resize +4 Resize split (up) n :vertical resize +4 Resize split (right) W!! c :w !sudo tee % >/dev/null:e! Save as root i u[s1z=]au Fix last spelling error (repeat.) ,S n vip:sort iu Sort in reverse lexicographic order ,S v :sort u Sort in reverse lexicographic order ,s n vip:sort u Sort in lexicographic order ,s v :sort u Sort in lexicographic order N n Nzz Keep cursor centered on screen when looking behind n n nzz Keep cursor centered on screen when looking ahead U n Redo zs n 1z= Fix spelling using first suggestion ^ n :set hls!set hls? Toggle on/off search highlights n :nohl Clear search highlights ,df n :setlocal spell!setlocal spell?:setlocal spelllang=fr Toggle spelling on/off (French) ,de n :setlocal spell!setlocal spell?:setlocal spelllang=en Toggle spelling on/off (English) n :let @s='\<'.expand('').'\>':%s/s// Substitute current word x sy:%s/s// Substitute current word ,p n :set invpaste:set paste? Toggle on/off paste mode YY n,v "+y Yank to clipboard n :Grep Grep (custom) n :Telescope find_files Fuzzy finder for files ,/ n :Telescope current_buffer_fuzzy_find Fuzzy search in buffer ,: n :Telescope command_history Fuzzy finder for command history ,, n :Telescope buffers Fuzzy finder for buffers ,f n :Telescope live_grep Live grep in working directory ,* n :lua require('telescope.builtin').grep_string({search = vim.fn.expand("")}) Fuzzy grep current word in working directory ,gg n :Telescope git_status Git status ,gC n :Telescope git_commits Git commit log ,gc n :Telescope git_bcommits Git buffer commit log ,gb n :Telescope git_branches Git branches ,gs n :Telescope git_stash Git stash ,q n :Telescope quickfix Telescope quickfix ,r n :Telescope oldfiles Telescope old files ,ww n :Telescope diagnostics LSP diagnostics ,T n :TestFile Test file (vimtest) ,t n :TestNearest Test nearest (vimtest) s v,x ywpa Send selection to nearest terminal ss n Vywpa Send line to nearest terminal gK n :Dasht Query documentation from Dash ,wq n vim.diagnostic.setqflist Show diagnostics in quickfix (LSP) [w n vim.diagnostic.goto_prev Go to previous diagnostic (LSP) ]w n vim.diagnostic.goto_next Go to next diagnostic (LSP) ,wd n vim.diagnostic.open_float Show diagnostic in a floating window (LSP) g= x vim.lsp.buf.range_formatting Format selection (LSP) g= n vim.lsp.buf.formatting Format selection (LSP) z= n,x vim.lsp.buf.code_action Code action (LSP) g0 n require("telescope.builtin").lsp_workspace_symbols Show workspace symbols (LSP) K n vim.lsp.buf.hover Show help for current symbol (LSP) i vim.lsp.buf.signature_help Show signature help (LSP) gd n require("telescope.builtin").lsp_definitions Show definition (LSP) gr n require("telescope.builtin").lsp_references Show references (LSP) zr n vim.lsp.buf.rename Rename symbol (LSP) gi n vim.lsp.buf.implementation Show implementation (LSP) I also have kind of an universal mapping, gs, which depending on filetype may compile a$\LaTeX\$ document or a C file and show its output, run a Python/Haskell/Lisp/Scheme script and show its output, etc. It is defined in relevant after/ftplugin/*.vim files. Finally, since I never found a good or reliable plugin to send command to a terminal, and I’ve tried many of the exiting ones for Vim or Neovim, I wrote my own commands: (It assumes that you have a terminal opened next to your buffer in a split, which is how I work in any case.)

" poor man send-to-repl features (we need to fire a REPL in a split first)
noremap ss Vy<C-w>wpa<CR><CR><Esc>
noremap s y<C-w>wpa<CR><CR><Esc>
xnoremap s y<C-w>wpa<CR><CR><Esc>


1. When I first drafted this cheatsheet, I was still using 15 plugins or so. Some packages broke at some point and I was too lazy to investigate why, or some were of too little use to justify keeping them. I don’t really miss anything with my current config, though. ↩︎

2. I recently switched to this leader key after having spent three years using the Space key as my leader, as a leftover of my Doom Emacs period. ↩︎