Skip to content
G. Bai edited this page Jun 5, 2021 · 33 revisions

List of shortcuts defined in vimrc

Generic shortcuts

  • ;: leader and localleader
  • :RC: reload vimrc and gvimrc (if gVim is running)
  • <C-n>: toggle relative numbering
  • <leader>y: copy to system clipboard
  • <leader>p: paste from system clipboard
  • <C-p>: toggle paste mode
  • <leader>bd: close current buffer and restore the previous one to current split
  • <leader>bn: move to next buffer
  • <leader>bp: move to previous buffer
  • <C-j>, <C-k>, <C-h>, <C-l>: move among windows
  • :NE: switch on line numbered from 0. E: ein. Works better without relative numbering
  • :NA: switch off line numbered from 0. A: aus

Plugin none-default shortcuts

  • <leader>i: IndentGuidesToggle, vim-indent-guides plugin
  • tb: call ToggleBackground() to toggle between dark and light colour schemes. The function uses vim-airline plugin
  • <leader>nt: toggle NERDTree and refresh Airline, NERDTree plugin
  • :TTS <theme>: call wrapper function TmuxlineThemeSnapshot(), which does TmuxlineSnapshot with (e.g. iceberg) to ~/.config/tmux/tmuxline.snapshot, tmuxline.vim plugin
  • <leader>l/: cd to b:vimtex.root, VimTeX plugin
  • <leader>ld: Stop & clean VimTeX, delete *.bbl file. VimTeX plugin
  • <C-m>: vim_markdown_preview_hotkey, vim-markdown-preview plugin
  • <leader>ff: search files, telescope.nvim (for Neovim 0.5+) or LeaderF plugin
  • <leader>fb: search buffers, telescope.nvim (for Neovim 0.5+) or LeaderF plugin
  • <C-s>: open snippet window in insert mode, LeaderF-snippet plugin

Cursor setting

gVim handles cursor automatically: blinking block in normal (command) mode, blinking bar in insert mode. To mimic this behavior for command-line Vim, I configure variables t_SI (INSERT mode), t_SR (REPLACE mode), and t_EI (NORMAL mode), respectively:

let &t_SI .= "\e[5 q" " SI = INSERT mode
let &t_SR .= "\e[4 q" " SR = REPLACE mode
let &t_EI .= "\e[1 q" " EI = NORMAL mode (ELSE)

There's no need to set tmux DCS escape sequence in vimrc. "tmux will keep track of the correct cursor shape when you switch windows/panes." as per https://stackoverflow.com/a/42118416/10039621. Also see this issue.

To intialise cursor shape on startup:

augroup reset_cursor_shape
  au!
  "autocmd VimEnter * startinsert | stopinsert
  autocmd VimEnter * normal! :startinsert :stopinsert
  "autocmd VimEnter * :normal :startinsert :stopinsert
  autocmd VimEnter * redraw!
augroup END

This works for ordinary Bash session and tmux session. silent !echo approach breaks cursor position when Vim exits, see this GitHub issue comment. redraw is necessary, see this issue.

And to reset cursor to blinking bar when Vim exits:

autocmd VimLeave * silent !echo -ne "\e[5 q"

Colour setting

Prevent wrong bg colour during rapid scrolling

https://github.com/microsoft/terminal/issues/832#issuecomment-502454504

if (&term =~ '^xterm' && &t_Co == 256)
  set t_ut= | set ttyscroll=1
endif

MacVim

See this section.

Plugin setting

Refreshing

Many functionalities changes the status line and may break it. To repair this, manually shoot AirlineRefresh command. Usually use in conjunction with airline#extensions#tabline#buffers#invalidate() in the next section.

Tabline

airline-tabline usually needs to be manually refreshed, by calling airline#extensions#tabline#buffers#invalidate(). This could be followed by AirlineRefresh command. See this issue.

TeX

If the current tex file is the main project file, show / as state indicator (nothing is shown by default):

let g:airline#extensions#vimtex#main = "/"

Also see TeX.

See TeX.

If you'd like better performance, install the C extension of the fuzzy matching algorithm, which is more than 10 times faster. See this link.

  • Install the C extension
:LeaderfInstallCExtension
  • Uninstall the C extension
:LeaderfUninstallCExtension