This is a Vim config (.vimrc
) for NeoVim, Vim 8 and Vim 7.3+
<Leader>
key is mapped to ,
for convenience.
- coc.nvim: Intellisense engine for vim8 & neovim, full language server protocol support as VSCode. Check its documents to gain full power of it.
- nerdcommenter: Comment/Uncomment your code with
<Leader>cc
,<Leader>c<Space>
, etc. - vim-easy-align: I have mapped
ga
to align code in normal and visual mode. For example, you can align a block of JSON map with:
viavipga:
orgaip:
. Check the plugin's document for details. - vim-fugitive and vim-signify give a git integration. You can invoke most git commands in Vim via
fugitive
's pre-defined functions, e.g.:Gblame
,:Glog
,:Gdiff
, and you can continue operating on the result interactively via some hotkeys. When you open or save a buffer (file),vim-signify
would indicate the differences from your VCS and you can jump among them via[c
and]c
(just like when you usevimdiff
). K
is the best way to check document of the current word.<Leader>t
is a convenient wrapper to grepTODO|FIXME|XXX
in current directory.
- fzf is my favorite fuzzy finder, before it I haved tried ctrlp and leaderF, neither of them was fast enough or bug free to use. Furthermore,
fzf
is integrated in your terminal by nature. I've mapped<Leader>f
,<Leader>b
,<Leader>m
and<Leader>g
to find in Files, Buffers, Modification history and Git files. Use<Ctrl>X
,<Ctrl>V
,<Ctrl>T
to open target file in a new window or tab. - vim-easymotion could be useful when you need quickly jump to somewhere in Vim. Take
<Leader><Leader>w
for a try. - vim-bookmarks maps keys to mark a line (
mm
), insert some notes (mi
), jump among markers (mn
,mp
) and show all markers (ma
) <Ctrl-o>
,<Ctrl-i>
to jump back and forth in the current buffer.- Window operations:
<Ctrl-w>s
,<Ctrl-w>v
to split a window.<Ctrl-h>
,<Ctrl-j>
,<Ctrl-k>
,<Ctrl-l>
to navigate among windows.<Ctrl-H>
,<Ctrl-J>
,<Ctrl-K>
,<Ctrl-L>
to expand the current window.<Ctrl-w>=
,<Ctrl-w>+
,<Ctrl-w>-
,<Ctrl-w> <
,<Ctrl-w> >
to adjust window size. (You can prepend a NUM like using a motion commond)
- Tab operations:
to
,tc
to open and close a tab.tp
,tn
to switch back and forth (just likegT
andgt
).NUM gt
to go to theNUM
th tab.
gf
to open a path (including URL) in Vim quickly.
- vim-plug: A super fast plugin manager. Run
:PlugInstall
,:PlugUpdate
to install and update plugins in parallel. - vim-airline enhances Vim's status line. It also works well with other plugins.
<Leader>1
to toggle tree view of project files. Check:help NERDTreeMappings
for its usage.<Leader>2
to toggle number.<Leader>3
to toggle foldenable for the current buffer, use<space>
to fold a single block.<Leader>4
to toggle paste mode.<Leader>5
and<Leader>6
is used tomake
a project.<Leader>7
and<Leader>8
to open and close quickfix window,<Leader>p
and<Leader>n
to jump back and forth. As for location list, just prepend another<Leader>
key, for example:<Leader><Leader>7
to open the location list window.<Leader>9
to toggle Tagbar<Leader>0
to grep the current word and<Leader><Leader>0
to invoke a plain grep command.<Leader>/
to disable highlight search.
Please check the Mappings
section in .vimrc
and plugins' manual for more information :)
Before cloning this repo, you need to install some external dependencies:
:grep
needs either ripgrep or the_silver_searcher for a faster grep- Tagbar depends on
ctags
for code parsing:
# On MacOS with Homebrew:
brew install cmake, ctags, ripgrep
# On Arch Linux:
sudo pacman -S cmake ctags ripgrep
# On Ubuntu Linux >= 13.10(Saucy):
sudo apt-get install cmake exuberant-ctags silversearcher-ag
For Golang developers, install gopls
and gofumpt
:
GO111MODULE=on go get golang.org/x/tools/gopls@latest
GO111MODULE=on go get mvdan.cc/gofumpt
(Other binary dependencies such as fzf
would be updated automatically during plugin update.)
Clone this repository into ~/.vim
:
git clone https://github.com/cherrot/vimrc.git ~/.vim
ln -sf ~/.vim/.vimrc ~/
If you use NeoVim like me, then you may check :help nvim-from-vim
to enable this vimrc
. (Only 3 lines config is needed!)
Now you could run vim
in your terminal. It will check and install all the plugins it needs.
Ignore the color scheme error for now (It should be fixed on your next start). This process will take a few minutes depending on your network bandwidth and CPU. Be patient :)
Now you can restart your Vim and welcome to the new world!
- (ArchLinux) If you get an error about
libtinfo
, you may need to installncurses5-compat-libs
via AUR. - If you want a python PEP8 lint, you need
flake8
installed viapip
systemwide or under your virtualenv only.
Make sure your ternimal is 256-color
. Run echo $TERM
in your terminal,
it should be either xterm-256color
or screen-256color
. If not, you need set it to your
terminal profile or export the environment variable.