" Basic options based on https://missing.csail.mit.edu/2020/editors/ nmap Q <Nop>" 'Q' in normal mode enters Ex mode. You almost never want this. set backspace=indent,eol,start set hidden set ignorecase set incsearch set laststatus=2 set mouse+=a set nocompatible set noerrorbells visualbell t_vb= setnumber set relativenumber set shortmess+=I set smartcase syntaxon
" lightline.vim set noshowmode if !has('gui_running') set t_Co=256 endif letg:lightline = { 'colorscheme': 'wombat' }
" nerdtree nnoremap<C-S-E> :NERDTree<CR> " Start NERDTree when Vim is started without file arguments. autocmd StdinReadPre * lets:std_in=1 autocmd VimEnter * ifargc() == 0 && !exists('s:std_in') | NERDTree | endif " Exit Vim if NERDTree is the only window remaining in the only tab. autocmd BufEnter * iftabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" vim-indent-guides setts=2sw=2 et letg:indent_guides_start_level=2 letg:indent_guides_enable_on_vim_startup = 1
" ycm " Let clangd fully control code completion letg:ycm_clangd_uses_ycmd_caching = 0 " Use installed clangd, not YCM-bundled clangd which doesn't get updates letg:ycm_clangd_binary_path = exepath("clangd")
" Set color scheme. colorscheme dracula
" Let vim automatically infer indents based on context set smartindent
" Mapping configurations let mapleader = " "" leader is space " Map jk to <ESC> imap jk <ESC> " Move vertically by visual line nmapj gj nmapk gk vmapj gj vmapk gk " Handle windows quicker nnoremap<leader>\| :vsp<CR> nnoremap<leader>- :sp<CR> map<C-h><C-w>h map<C-j><C-w>j map<C-k><C-w>k map<C-l><C-w>l
Finally, start vim and run :PlugInstall to install all the plugins using vim-plug. See the basic usage of these plugins here.
" If you open this file in Vim, it'll be syntax highlighted for you.
" Vim is based on Vi. Setting `nocompatible` switches from the default " Vi-compatibility mode and enables useful Vim functionality. This " configuration option turns out not to be necessary for the file named " '~/.vimrc', because Vim automatically enters nocompatible mode if that file " is present. But we're including it here just in case this config file is " loaded some other way (e.g. saved as `foo`, and then Vim started with " `vim -u foo`). set nocompatible
" Turn on syntax highlighting. syntaxon
" Disable the default Vim startup message. set shortmess+=I
" Show line numbers. setnumber
" This enables relative line numbering mode. With both number and " relativenumber enabled, the current line shows the true line number, while " all other lines (above and below) are numbered relative to the current line. " This is useful because you can tell, at a glance, what count is needed to " jump up or down to a particular line, by {count}k to go up or {count}j to go " down. set relativenumber
" Always show the status line at the bottom, even if you only have one window open. set laststatus=2
" The backspace key has slightly unintuitive behavior by default. For example, " by default, you can't backspace before the insertion point set with 'i'. " This configuration makes backspace behave more reasonably, in that you can " backspace over anything. set backspace=indent,eol,start
" By default, Vim doesn't let you hide a buffer (i.e. have a buffer that isn't " shown in any window) that has unsaved changes. This is to prevent you from " " forgetting about unsaved changes and then quitting e.g. via `:qa!`. We find " hidden buffers helpful enough to disable this protection. See `:help hidden` " for more information on this. set hidden
" This setting makes search case-insensitive when all characters in the string " being searched are lowercase. However, the search becomes case-sensitive if " it contains any capital letters. This makes searching more convenient. set ignorecase set smartcase
" Enable searching as you type, rather than waiting till you press enter. set incsearch
" Unbind some useless/annoying default key bindings. nmap Q <Nop>" 'Q' in normal mode enters Ex mode. You almost never want this.
" Disable audible bell because it's annoying. set noerrorbells visualbell t_vb=
" Enable mouse support. You should avoid relying on this too much, but it can " sometimes be convenient. set mouse+=a
" Try to prevent bad habits like using the arrow keys for movement. This is " not the only possible bad habit. For example, holding down the h/j/k/l keys " for movement, rather than using more efficient movement commands, is also a " bad habit. The former is enforceable through a .vimrc, while we don't know " how to prevent the latter. " Do this in normal mode... nnoremap<Left> :echoe"Use h"<CR> nnoremap<Right> :echoe"Use l"<CR> nnoremap<Up> :echoe"Use k"<CR> nnoremap<Down> :echoe"Use j"<CR> " ...and in insert mode inoremap<Left><ESC>:echoe"Use h"<CR> inoremap<Right><ESC>:echoe"Use l"<CR> inoremap<Up><ESC>:echoe"Use k"<CR> inoremap<Down><ESC>:echoe"Use j"<CR>
" lightline.vim set noshowmode if !has('gui_running') set t_Co=256 endif letg:lightline = { 'colorscheme': 'wombat' }
" nerdtree nnoremap<C-S-E> :NERDTree<CR> " Start NERDTree when Vim is started without file arguments. autocmd StdinReadPre * lets:std_in=1 autocmd VimEnter * ifargc() == 0 && !exists('s:std_in') | NERDTree | endif " Exit Vim if NERDTree is the only window remaining in the only tab. autocmd BufEnter * iftabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
" vim-indent-guides setts=2sw=2 et letg:indent_guides_start_level=2 letg:indent_guides_enable_on_vim_startup = 1
" ycm " Let clangd fully control code completion letg:ycm_clangd_uses_ycmd_caching = 0 " Use installed clangd, not YCM-bundled clangd which doesn't get updates letg:ycm_clangd_binary_path = exepath("clangd")
" Set color scheme. colorscheme dracula
" Let vim automatically infer indents based on context set smartindent
" Mapping configurations " leader is space let mapleader = " "
" Insert mode, no recursively " Map jk to <ESC>. inoremap jk <ESC>
" Normal mode, no recursively " Move vertically by visual line. nnoremapj gj nnoremapk gk
" Handle windows quicker nnoremap<leader>\| :vsp<CR>" don't forget the escape character nnoremap<leader>- :sp<CR> map<C-h><C-w>h map<C-j><C-w>j map<C-k><C-w>k map<C-l><C-w>l
To use vim-plug to install the plugins, run:
1
:PlugInstall
Note that I install YouCompleteMe with clangd support (Learn more here). I met an issue here. See Q&A.
In JetBrains IDEs, I use IdeaVim and configure it like this:
1 2 3 4 5 6 7 8 9 10 11 12 13
" .ideavimrc "" Source your .vimrc source ~/.vimrc
"" -- Map IDE actions to IdeaVim -- https://jb.gg/abva4t "" Map \r to the start run map \r <Action>(Run)
"" Map \d to start debug map \d <Action>(Debug)
"" Map \bto toggle the breakpoint on the current line map \b<Action>(ToggleLineBreakpoint)
The default file tree hotkey is Alt + 1. I add Ctrl + Shift + E.
Q&A
ImportError when I try to install ycm
1
The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected error while loading the YCM core library. Type ':YcmToggleLogs <...>.log' to check the logs.
Log:
1
ImportError: /home/<...>/miniconda3/lib/libstdc++.so.6: version `GLIBCXX_3.4.30` not found (required by /home/<...>/.vim/plugged/YouCompleteMe/third_party/ycmd/ycm_core.cpython-311-x86_64-linux-gnu.so)
This is an issue caused by conda. You should run install.py using the system python, not the conda one. Learn more here.