Created
August 16, 2012 16:09
-
-
Save wikitopian/3371393 to your computer and use it in GitHub Desktop.
Dealing with tabs and spacing in Vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" The final answer to the Tab Question | |
set colorcolumn=80 | |
set shiftwidth=4 | |
set tabstop=4 | |
set softtabstop=4 | |
set expandtab | |
set list listchars=tab:»·,trail:· | |
function! SwitchTab() | |
setlocal expandtab! | |
endfunction | |
vnoremap <Leader><tab> <Esc>:call SwitchTab()<CR> | |
inoremap <Leader><tab> <Esc>:call SwitchTab()<CR> | |
nnoremap <Leader><tab> <Esc>:call SwitchTab()<CR> | |
augroup wspace | |
autocmd! | |
" Visual warning about trailing whitespace and mixed up spacing | |
highlight ExtraWhitespace ctermbg=red guibg=red | |
match ExtraWhitespace /\s\+$\| \+\t\|\t \+/ | |
autocmd BufWinEnter * match ExtraWhitespace /\s\+$\| \+\t\|\t \+/ | |
autocmd InsertEnter * match ExtraWhitespace /\s\+$\| \+\t\|\t \+/ | |
autocmd InsertLeave * match ExtraWhitespace /\s\+$\| \+\t\|\t \+/ | |
autocmd BufWinLeave * call clearmatches() | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment