Skip to content

Instantly share code, notes, and snippets.

@plembo
Last active August 12, 2026 20:00
Show Gist options
  • Select an option

  • Save plembo/1b449acd668ff97f89e4ab1825c47fe1 to your computer and use it in GitHub Desktop.

Select an option

Save plembo/1b449acd668ff97f89e4ab1825c47fe1 to your computer and use it in GitHub Desktop.
My vimrc

Going beyond the defaults with vim

I really didn't care about formatting until I started learning to program in python.

Now I have to.

Here are some notes on going beyond the defaults with the vim editor. The thing about this stuff is that it really can lead you into a lot of tinkering and experimentation: so be prepared for that.

I generally use a .vimrc dotfile for both CLI and GUI versions of vim. Some people like to use .gvimrc for directives that only apply to the GUI.

color schemes

A good color scheme can improve productivity in vim, just as in any other editor. Several built-in themes are available, like slate, but I prefer Josh Dick's onedark.vim (inspired by the Atom editor's default OneDark theme).

plugins

Plugins can provide vim with useful features not in the base package.

A good minimalist plugin manager is June Gunn's vim-plug. After updating .vimrc with each plugin's GitHub HTTPS URL (or the significant part after "https://github.com"), run :PlugInstall to install the plugins. In some cases further tweaking of .vimrc or other configuration files may be required.

The below configurations have been tested on both vim 8 vim 9, but note that variations in ordering and specific combinations may have unintended results.

.vimrc examples

Customize vim's behavior with a .vimrc file, like this one:

" My vimrc                                                                      
set nocompatible                                                                
filetype on                                                                     
filetype indent on                                                              
set number                                                                      
set ignorecase                                                                  
set tabstop=4                                                                   
set shiftwidth=4                                                                
set softtabstop=4                                                               
set expandtab                                                                   
set backspace=indent,eol,start                                                  
set nobackup                                                                    
set encoding=utf-8                                                              
set fileencodings=ucs-bom,utf-8                                                 
set formatoptions=1                                                             
set fileformat=unix                                                             
set noerrorbells                                                                
set vb t_vb=                                                                    
syntax on                                                                       
colorscheme slate                                                               

Here's what it looks like with a good color scheme, a nice font, and some helpful plugins loaded (including better markdown support):

" My vimrc for programming                                                      
set nocompatible                                                                
filetype on                                                                     
filetype indent on                                                              
" set number                                                                    
set ignorecase                                                                  
set tabstop=4                                                                   
set shiftwidth=4                                                                
set softtabstop=4                                                               
set expandtab                                                                   
set autoindent                                                                  
set fileformat=unix                                                             
set backspace=indent,eol,start                                                  
set nobackup                                                                    
set encoding=utf-8                                                              
set fileencodings=ucs-bom,utf-8                                                 
set formatoptions=1                                                             
set guifont=Fira\ Code\ Retina\ 12                                              
set colorcolumn=80                                                              
set noerrorbells                                                                
set vb t_vb=                                                                    
set mouse=r                                                                     
" netrw (vim file explorer) options                                             
let g:netrw_banner = 0                                                          
let g:netrw_liststyle = 2                                                       
let g:netrw_winsize = 25                                                        
let g:netrw_list_hide='\(^\|\s\s\)\zs\.\S\+'                                     
" Setup plugin manager (vim-plug)                                               
call plug#begin()                                                               
" OneDark theme                                                                 
Plug 'joshdick/onedark.vim'                                                     
" Airline fonts                                                                 
Plug 'vim-airline/vim-airline'                                                  
" Better indenting for python                                                   
Plug 'vim-scripts/indentpython.vim'                                             
" ALE for linters                                                               
Plug 'dense-analysis/ale'                                                       
" Better javascript highlighting                                                
Plug 'pangloss/vim-javascript'                                                  
" Markdown code block suport                                                    
Plug 'plasticboy/vim-markdown'                                                  
call plug#end()                                                                 
" vim airline options                                                           
let g:airline_powerline_fonts = 1                                               
" load the onedark theme                                                        
syntax on                                                                       
colorscheme onedark                                                             
" ALE linter configuration                                                      
let g:ale_linters = {'python': ['pylint'], 'javascript': ['eslint']}            
let g:ale_lint_on_enter = 0                                                     
" Markdown config                                                               
let g:vim_markdown_fenced_languages = ['js=javascript']                         
let g:vim_markdown_folding_disabled = 1                                         
let g:vim_markdown_conceal = 0                                                  

Status bar plugins like vim-airline (and its inspiration, powerline) may be a hard sell to minimalists, especially because they require special fonts (sudo apt install fonts-powerline), but I'm finding it useful.

I used to load vim-polyglot here, until I saw it display commas as pipes inside csv files: very disconcerting!After finally reading its doc carefully I realized I really didn't need it...
yet.

For linting I install ALE (the "Asynchronous Lint Engine") and set it to disabled by default so it only runs on invoking :ALEToggle inside a file.

Windows variations

On Windows vimrc is supposed to be stored under %USERPROFILE%\vimfiles as vimrc (no leading dots or underscores). But if you're also using Git for Windows (GfW), put vimrc in the root of %USERPROFILE% as _vimrc (with the leading underscore). You'll find that vim in GfW automatically saves _viminfo there are well.

On most Windows systems %USERPROFILE% maps to the root of the user's home folder, like "C:\Users\myuser". The full path to vimrc would then be like "C:\Users\myuser\ _vimrc". If %USERPROFILE% is mapped to a weird place by a group policy (like an old server file share that no longer exists), you can set up a custom User environment variable by opening a Command Prompt and
typing setx HOME "C:\Users\myuser". The editor will then be able to find your _vimrc and vimfiles under "C:\Users\myuser".

References

Josh Dick. "onedark.vim". GitHub, https://github.com/joshdick/onedark.vim.

Adam Stankiewicz. "vim polyglot". GitHub, https://github.com/sheerun/vim-polyglot.

Vim Airline Project. "vim airline". GitHub, https://github.com/vim-airline/vim-airline.

June Gunn. "vim-plug". GitHub, https://github.com/junegunn/vim-plug.

Daniel Miessler. "Learn Vim for the Last Time: A Tutorial and Primer". Daniel Miessler, 6 May 2021, https://danielmiessler.com/study/vim/.

Heiker Curiel. "Using netrw, vim's builtin file exlorer". Devlog, 10 January 2021, https://vonheikemen.github.io/devlog/tools/using-netrw-vim-builtin-file-explorer/.

Ricardo Girardi. "Top five Vim plugins for sysadmins". Red Hat Enable Sysadmin, 16 October 2020, https://www.redhat.com/sysadmin/five-vim-plugins.

Carlo Teubner. "Vim help files". vim help, https://vimhelp.org/.

Christian Brabant. "VIM FAQ". vim help, https://vimhelp.org/vim_faq.txt.html.

Arnold Robbins. vi Editor Pocket Reference. O'Reilly, 1999.

PreserveVIM. "vim_markdown". GitHub, https://github.com/preservim/vim-markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment