Set up my Vim

Page content

Install jellybeans

I use a color scheme called “Jellybeans”.

mkdir ~/.vim
cd ~/.vim
sudo yum install -y git
git clone https://github.com/nanotech/jellybeans.vim
mkdir colors
mv jellybeans.vim/colors/jellybeans.vim ~/.vim/colors/jellybeans.vim
vim ~/.vimrc
colorscheme jellybeans
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set number
syntax on
set t_Co=256
set foldmethod=syntax

Add the line into ~/.bashrc,

TERM=xterm-256color

vim plugin manager

https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation

Add the following in .vimrc:

let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
  silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

Prepare plugins directory

mkdir .vim/plugged

Add a plugin. in .vimrc. An example (rust-lang/rust.vim):

call plug#begin('~/.vim/plugged')
  Plug 'rust-lang/rust.vim'
call plug#end()

Don’t use double quote.

Install the plugin in run the command in Vim.

:PlugInstall

Here is the sample output:

Updated. Elapsed time: 0.730500 sec.       |colorscheme jellybeans
[=]                                        |set expandtab
                                           |set tabstop=2
- Finishing ... Done!                      |set softtabstop=2
- rust.vim: Resolving deltas: 100% (18/18),|set shiftwidth=2
                                           |set number
                                           |syntax enable
                                           |filetype plugin indent on
                                           |set t_Co=256
                                           |"set foldmethod=syntax
                                           |

The pluging is downloaded under .vim/plugged:

$ ls .vim/plugged/
rust.vim

CoC plugin

Plug 'neoclide/coc.nvim', {'branch': 'release'}

Run :CocConfig, and add language dependent json configuration.

replace characters

## Decide each matches
:s/before/after/g

## Decide at once
:%s/before/after/g

Memo: My .vimrc

colorscheme jellybeans
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set number
syntax enable
filetype plugin indent on
set t_Co=256
set foldmethod=syntax
set encoding=UTF-8


let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
  silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

call plug#begin('~/.vim/plugged')
  Plug 'rust-lang/rust.vim'
  Plug 'neoclide/coc.nvim', {'branch': 'release'}
  Plug 'preservim/nerdtree'
  Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
  Plug 'ryanoasis/vim-devicons'
call plug#end()

" NERDTree
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
" For NERDTree icon
" https://gist.github.com/matthewjberger/7dd7e079f282f8138a9dc3b045ebefa0