First, delete all vim-related ones.

cd

rm -rf .vim*
Copy the code

Create your own.vIMrc

vim .vimrc
Copy the code

Some basic Settings

Add the following code to.vimrc

" basic set
set number
set noswapfile
set encoding=utf-8
set fileencodings=utf-8,gb18030
set backspace=eol,start,indent
set laststatus=2
set colorcolumn=80
set cursorline
set linebreak
set autoindent
set ignorecase
set smartcase
set ruler
set diffopt+=internal,indent-heuristic,algorithm:patience
set showcmd
set clipboard^=unnamed,unnamedplus
set showmode
set mouse=a
set tabstop=2
set shiftwidth=4
set expandtab
set softtabstop=2
set showmatch
set incsearch
set nobackup
set autoread
set wildmenu
set wildmode=longest:list,full
set nofoldenable

filetype plugin indent on
syntax on

Copy the code

With the above Settings, your Vim will be a little more usable.

For the meaning of each parameter, you can see ruan Yifeng’s introduction to VIM configuration

Install vim plug-in

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Copy the code

I use vim-Plug to manage the vim plug-in configuration, which is relatively easy to use.

The idea is to clone github’s vim configuration and load it.

Install some plug-ins

Continue adding the following code in.vimrc

" Plugs
call plug#begin()
Plug 'luochen1990/rainbow'
Plug 'jiangmiao/auto-pairs'
Plug 'mechatroner/rainbow_csv'
Plug 'liuchengxu/space-vim-theme'
Plug 'lvht/mru'
Plug 'preservim/tagbar'
Plug 'preservim/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'ryanoasis/vim-devicons'
Plug 'liuchengxu/nerdtree-dash'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'liuchengxu/eleline.vim'
Plug 'tpope/vim-fugitive'
call plug#end()
Copy the code

These are some of the plug-ins I use a lot

  • Rainbow is a rainbow with a different color for each bracket to make the code more readable
  • Auto-pairs indicates automatic completion of parentheses
  • Rainbow_csv is a plugin that makes opening a CSV file look better
  • Space-vim-theme is a theme of Vim
  • Mru is the most commonly used file these days
  • Tagbar displays the structure of the code
  • Nerdtree + nerdtree-git-plugin + vim-devicons + nerdtree-dash + nerdtree-git-plugin + vim-devicons + nerdtree-dash
  • Vim-go Writing go is mandatory
  • Tabular + vim- markDown
  • The Eleline status bar looks better
  • Git plug-in for Vim-Fugitive Vim

Custom Settings for plug-ins

With so many plug-ins installed, it is possible to customize them. Some plug-ins provide some variables. We can customize them by using let g: XXX

These Settings are also in VIMRC, under the plug-in installation

" plug settings
let g:rainbow_active=1
Copy the code

The setting of the keymap

We can set up some shortcuts to speed things up.

Vim has a leader key, which is used to press and then press other keys to trigger commands. The leader key is there to prevent the user from overwriting the default shortcut key. Vim is the leader of the default key |, enter the vertical bar in the above.

" key map nnoremap <silent> <c-m> :Mru<cr> nnoremap <silent> <c-p> :call fzf#Open()<cr> nnoremap <silent> <leader>t :TagbarToggle<cr> nnoremap <silent> <leader>e :NERDTreeToggle<cr> nnoremap <silent> <leader>f :NERDTreeFind<cr> nnoremap  <silent> <leader>c :call lv#Term()<cr>Copy the code
  • CTRL + M opens the most recently used file
  • CTRL + P calls FZF to search for files
  • \ + t Opens or closes the file outline
  • \ + e Opens or closes the file directory
  • \ + f Opens the file directory and quickly locates the current file location
  • \ + c Open the terminal on the current page and enter exit to return to the VIm interface

If you want to be like mine

Check out this Github project: github.com/zhenfeng-zh…

git clone --recursive https://github.com/zhenfeng-zhu/vim.git ~/.vim

ln -s ~/.vim/init.vim ~/.vimrc
Copy the code

Then you can happily customize yourself.