Setup Vim for Development
Minimum setup for using Vim as an Integrated Development Environment (IDE).
Steps
- First, install Vim (version 9.x):
sudo apt install vim - Create a
.vimrcfile in your home directory (Refer to Appendix A for example file content). - Follow instructions for installing Vim-Plug for Vim plugin management.
- Follow instructions for installing NERDTree for providing a file tree pane in Vim.
- Follow instructions for installing NERDTree Git Plugin for providing Git status flags in the NERDTree file pane.
- Follow instructions for installing Vim Autosave.
- Install Clangd for LSP server:
sudo apt install clangd - Follow instructions for installing ALE for providing LSP client for Vim.
- Open Vim, type the
:PlugInstallcommand and wait until done, then quit Vim. - Using the previous linked sites, add the desired configuration lines for NERDTree and ALE (see Appendix B below).
- Follow instructions for installing VimDevIcons.
- Download a Nerd Font (I chose ‘JetBrainsMono Nerd Font’).
- Decompress and install the font files to the system font folder via Terminal (example based on the one I chose):
sudo unzip JetBrainsMono.zip -d /usr/share/fonts/ - Update the system font cache with the following command:
fc-cache -vf - Open Terminal, open the ‘Preferences’ pane, and set the font to the chosen Nerd font.
- Close Terminal.
- Open Terminal and verify the font has changed to your chose Nerd font.
- Add configuration for Vim built-in debugger ‘Termdebug’ to be loaded at the start of each Vim session (see Appendix B below).
Here is what Vim looks like upon opening with a directory argument (vim <directory>) after the configuration is done with NERDTree, ALE, and VimDevIcons plugins active:


Tips and tricks:
- The built-in terminal can be invoked with the
:terminalcommand. - Configure vimrc to have the built-in terminal enter insert mode upon opening (see Appendix B below).
- Use
[Ctrl] + wwto switch between the NERDTree pane and the other pane(s). - This GitHub page has a list of plugins for Vim/NeoVim, examine and install at your own risk.
For more detailed information and examples, please use your preferred search engine. I will correct mistakes as I have time.
Appendix A – Minimum vimrc setup
" Disable compatibility with vi which can cause unexpected issues.
set nocompatible
" Enable type file detection. Vim will be able to try to detect the type of file in use.
filetype on
" Enable plugins and load plugin for the detected file type.
filetype plugin on
set omnifunc=syntaxcomplete#Complete
" Load an indent file for the detected file type.
filetype indent on
" Turn syntax highlighting on.
syntax on
" Add numbers to each line on the left-hand side.
set number
" Set shift width to 4 spaces.
set shiftwidth=4
" Set tab width to 4 columns.
set tabstop=4
" Use space characters instead of tabs.
set expandtab
" Do not save backup files.
set nobackup
" Do not let cursor scroll below or above N number of lines when scrolling.
set scrolloff=10
" Do not wrap lines. Allow long lines to extend as far as the line goes.
set nowrap
" While searching though a file incrementally highlight matching characters as you type.
set incsearch
" Ignore capital letters during search.
set ignorecase
" Override the ignorecase option if searching for capital letters.
" This will allow you to search specifically for capital letters.
set smartcase
" Show partial command you type in the last line of the screen.
set showcmd
" Show the mode you are on the last line.
set showmode
" Show matching words during a search.
set showmatch
" Use highlighting when doing a search.
set hlsearch
" Set the commands to save in history default number is 20.
set history=1000
" Enable auto completion menu after pressing TAB.
set wildmenu
" Make wildmenu behave like similar to Bash completion.
set wildmode=list:longest
" There are certain files that we would never want to edit with Vim.
" Wildmenu will ignore files with these extensions.
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
" Highlight cursor line underneath the cursor horizontally.
set cursorline
" Highlight cursor line underneath the cursor vertically.
set cursorcolumn
Appendix B – My current “compelete” vimrc file
" Disable compatibility with vi which can cause unexpected issues.
set nocompatible
" Enable type file detection. Vim will be able to try to detect the type of file in use.
filetype on
" Enable plugins and load plugin for the detected file type.
filetype plugin on
set omnifunc=syntaxcomplete#Complete
" Load an indent file for the detected file type.
filetype indent on
" Turn syntax highlighting on.
syntax on
" Add numbers to each line on the left-hand side.
set number
" Set shift width to 4 spaces.
set shiftwidth=4
" Set tab width to 4 columns.
set tabstop=4
" Use space characters instead of tabs.
set expandtab
" Do not save backup files.
set nobackup
" Do not let cursor scroll below or above N number of lines when scrolling.
set scrolloff=10
" Do not wrap lines. Allow long lines to extend as far as the line goes.
set nowrap
" While searching though a file incrementally highlight matching characters as you type.
set incsearch
" Ignore capital letters during search.
set ignorecase
" Override the ignorecase option if searching for capital letters.
" This will allow you to search specifically for capital letters.
set smartcase
" Show partial command you type in the last line of the screen.
set showcmd
" Show the mode you are on the last line.
set showmode
" Show matching words during a search.
set showmatch
" Use highlighting when doing a search.
set hlsearch
" Set the commands to save in history default number is 20.
set history=1000
" Enable auto completion menu after pressing TAB.
set wildmenu
" Make wildmenu behave like similar to Bash completion.
set wildmode=list:longest
" There are certain files that we would never want to edit with Vim.
" Wildmenu will ignore files with these extensions.
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
" Highlight cursor line underneath the cursor horizontally.
set cursorline
" Highlight cursor line underneath the cursor vertically.
set cursorcolumn
" color theme
colors shine
set completeopt=menu,popup,noinsert,noselect
set lazyredraw
set mouse=a
set noswapfile
set colorcolumn=80
call plug#begin()
Plug 'preservim/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'dense-analysis/ale'
Plug 'ryanoasis/vim-devicons'
Plug '907th/vim-auto-save'
call plug#end()
" Start NERDTree when Vim starts with a directory argument.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
\ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
autocmd BufEnter * if winnr() == winnr('h') && bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
" ALE configuration
let g:ale_completion_enabled = 1
let g:ale_cpp_clangd_executable = '/usr/bin/clangd'
let g:ale_cpp_clangd_options = '--log=verbose --header-insertion=iwyu --header-insertion-decorators=true --all-scopes-completion=true --pretty --background-index --limit-results=500 --completion-style=detailed'
let g:ale_hover_to_floating_preview = 1
augroup ale_hover_cursor
autocmd!
autocmd CursorHold * ALEHover
augroup END
" automatically enter insert mode when the terminal buffer is opened
autocmd BufEnter * if &buftype == 'terminal' | :startinsert | endif
" load built-in Vim debugger at start of session
packadd! termdebug
let g:auto_save = 1
let g:auto_save_events = ["TextChanged"]