Skip to content

Instantly share code, notes, and snippets.

@soardex
Created December 8, 2016 14:37
Show Gist options
  • Save soardex/fbad6dce6eb165131ff967d3ba61e721 to your computer and use it in GitHub Desktop.
Save soardex/fbad6dce6eb165131ff967d3ba61e721 to your computer and use it in GitHub Desktop.
Show List Of Whitespace And Expand Tabs On VIM
" answer from http://stackoverflow.com/a/2159997/1406063
" use 4 spaces for tabs
set tabstop=4 softtabstop=4 shiftwidth=4
" display indentation guides
set list listchars=tab:❘-,trail:·,extends:»,precedes:«,nbsp:×
" convert spaces to tabs when reading file
autocmd! bufreadpost * set noexpandtab | retab! 4
" convert tabs to spaces before writing file
autocmd! bufwritepre * set expandtab | retab! 4
" convert spaces to tabs after writing file (to show guides again)
autocmd! bufwritepost * set noexpandtab | retab! 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment