Install/config gnome vim
if vim --version
give you -clipboard
, then you need to install gnome vim:
sudo pacman -S gvim # arch
sudo apt install vim-gnome #ubuntu
Install and Config Nerd Font
Nerd font is required by couple of plug in (vim-devicon)
-
Download font from here
-
Unzip and copy to ~/.fonts
-
Run the command fc-cache -fv to manually rebuild the font cache
-
run command fc-list grep to verify nerd font install correctly
Set Guifont for Nerd Font
if you are using neovim, then you need change the font of the terminal and then restart vim, if you use vim then you need to use
:set guifont=JetBrains\ Mono\ Nerd\ Font:h10
to implement the font
verify the font install correctly
in vim :
:echo g:WebDevIconsUnicodeDecorateFileNodesDefaultSymbol
if you see the icon then you are fine, it you see some weird icon, then it is not.
Set up vimrc or init.vim file
The config file is in ~/.vimrc
or ~/.config/nvim/init.vim
, basic config
my vim config is here
set vim color pattern
mkdir ~/.vim/colors
, copy the *.vim
file into this folder, then update ~/.vimrc file:
then copy the color vim file into the folder:
#neovim
wget https://raw.githubusercontent.com/AlessandroYorba/Alduin/master/colors/alduin.vim -O ~/.config/nvim/colors/alduin.vim
#vim:
wget https://raw.githubusercontent.com/AlessandroYorba/Alduin/master/colors/alduin.vim -O ~/.vim/colors/alduin.vim
" color scheme
let g:alduin_Shout_Dragon_aspect = 1
colorscheme alduin
** I used color scheme called : alduin
install plugin management tool : vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Add bunch of plugins in ~/.vimrc
, then run :PluginInstall
to install them
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'airblade/vim-gitgutter'
Plugin 'jiangmiao/auto-pairs'
Plugin 'tpope/vim-surround'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/nerdcommenter'
Plugin 'bagrat/vim-buffet'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'easymotion/vim-easymotion'
Plugin 'ryanoasis/vim-devicons'
Plugin 'JamshedVesuna/vim-markdown-preview;
Plugin 'ycm-core/YouCompleteMe'
Map the <leader> key to comma
let mapleader = ","
Config NERDTree
noremap <leader>t : NERDTreeToggle<CR>
“O” - expand all; “o” expand current node
activate Vimdevicon
Once install the vim-devicon, you need use following command to activate in .vimrc
let g:webdevicons_enable = 1
let g:webdevicons_enable_nerdtree = 1
let g:webdevicons_enable_airline_statusline = 1
setup vim-markdown-preview
install grip:
pip3 install grip
in .vimrc:
let vim_markdown_preview_github=1
then <c-p> to launch preview
Set up coc.nvim
-
Install nodejs
curl -sL install-node.now.sh/lts | sudo bash
-
add following in vimrc/init.vim if you use vundle
Plugin 'neoclide/coc.nvim'
then resource and run
:PluginInstall
-
Check health
run :checkhealth, if you see lot of
ok
then you should be fine. run :CocInfo to see the information -
Install java
run :CocInstall coc-java
-
Setup JAVA_HOME
This is same step as set up for VS Code, the tricky thing is some time the openjdk doesn’t work. It complains that JAVA_HOME is not pointing to JDK
I downloaded oracle jdk and install fixed this issue. Here is the instruction how to install on linux mint.
-
update the init.vim with coc.nvim config.
you can find the coc.nvim configuration here
I didn’t completely copy-paste since there are some keymaps are conflicting.
-
Some useful shortcuts:
‘gd’ - goto declare. <c-o> come back ‘gy’ - goto class definition ‘gi’ - goto implement (from interface to concrete object) ‘gr’ - goto reference ‘[g’ - goto next error. ‘]g’ - goto prev error ‘K’ - show document of a class
Setup ctags
Install ‘ctags’
sudo apt install exuberant-ctags
In your java project directory, run ctags
ctags -R --languages=Java
update .vimrc
set:
set tags=tags;/
Setup YouCompleteMe
plugin
-
update
~/.config/nvim/init.nvim
: add Plugin ‘ycm-core/YouCompleteMe’ -
install cmake
sudo apt install cmake
- call
install.py
cd /home/rongshen/.vim/bundle/YouCompleteMe
python3 ./install.py --java-completer
- restart nvim
setup surround
install:
git clone https://tpope.io/vim/surround.git ~/.vim/bundle/surround
shortcuts:
- add surround on the line:
yss
+ character - add surround on the word:
ysiw
+ character: ysiw + “ - change surround:
cs
+ original character + replace character - remove surround:
ds
+ character - multiple line surround: shift + v + shift + s + character” V + select lines + S + “
easy motion
leader + f : jump to character leader + w : jump to word leader + s : jump to 2 characters - you type 2 in command line leader + L : move to line
move to pathogen
- Install Pathogen:
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
- enable Pathogen
in ~/.vimrc
add “execute pathogen#infect()”
- Install plugins
clone whatever plugins you want into ~/.vim/bundle
folder
git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree
Here is the plugins that I installed
total 36
drwxrwxr-x 9 rongshen rongshen 4096 Mar 15 23:07 ./
drwxrwxr-x 5 rongshen rongshen 4096 Mar 15 22:16 ../
drwxrwxr-x 10 rongshen rongshen 4096 Mar 15 22:21 nerdtree/
drwxrwxr-x 6 rongshen rongshen 4096 Mar 15 22:33 surround/
drwxrwxr-x 8 rongshen rongshen 4096 Mar 15 22:52 vim-airline/
drwxrwxr-x 8 rongshen rongshen 4096 Mar 15 22:53 vim-airline-themes/
drwxrwxr-x 5 rongshen rongshen 4096 Mar 15 23:05 vim-buffet/
drwxrwxr-x 5 rongshen rongshen 4096 Mar 15 22:56 vim-colorschemes/
drwxrwxr-x 8 rongshen rongshen 4096 Mar 15 23:07 vim-easymotion/