Vim Settings

Plugin Manager - vim-plug

https://github.com/junegunn/vim-plug

Type the following command:

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

For Windows, type the following command:

iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | ni $HOME/vimfiles/autoload/plug.vim -Force

Add/Create a vim-plug section to your ~/.vimrc.

  1. Begin the section with call plug#begin()
  2. List the plugins with Plug commands
  3. call plug#end() to update &runtimepath and initialize plugin system
  • Automatically executes filetype plugin indent on and syntax enable. You can revert the settings after the call. e.g. filetype indent off, syntax off, etc.

Example

" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')

" Make sure you use single quotes

" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'

" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'

" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

" On-demand loading
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }

" Using a non-default branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }

" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }

" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }

" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }

" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'

" Initialize plugin system
call plug#end()

Reload .vimrc and type :PlugInstall in vim to install plugins.

NERDTree

The NERDTree is a file system explorer for the Vim editor. Using this plugin, users can visually browse complex directory hierarchies, quickly open files for reading or editing, and perform basic file system operations.

call plug#begin('~/.vim/plugged')

Plug 'preservim/nerdtree'

call plug#end()

" Automatic start nerdtree
autocmd VimEnter * NERDTree

" Start NERDTree and put the cursor back in the other window.
autocmd VimEnter * NERDTree | wincmd p

Use Ctrl + w and left/right arrow to switch between windows.

Use Ctrl + w and Ctrl + o to close the other window.

Theme: gruvbox

call plug#begin('~/.vim/plugged')

Plug 'morhetz/gruvbox'

call plug#end()

" Automatic enable theme
colorscheme gruvbox

Some setting

Type the following command into ~/.vimrc

set tabstop=4
set shiftwidth=4

" Show Line Number
set nu

" Set Auto Indent
set ai

" Attach mouse, you can choose with mouse
" Use Ctrl+Insert to copy and Shift+Insert to paste
set mouse=a

Terminal

To use terminal in vim, type :term.

Type the following command into ~/.vimrc

set splitbelow
set termwinsize=15x0

You Complete Me

https://wiki.archlinux.org/title/Vim/YouCompleteMe#Installation