Created
January 22, 2012 20:58
-
-
Save wolever/1658762 to your computer and use it in GitHub Desktop.
Vim functions to change tab treatment
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
" Usage: | |
" - copy+paste into ~/.vimrc or ~/.vim/plugin/tabtreatment.vim | |
" - Call with ':call HardTabs(...)' or ':call SoftTabs(...)' | |
" HardTabs([width=8]): Sets up the current buffers so that: | |
" - '\t' is 'widith' wide | |
" - '<tab>' inserts a '\t' | |
" - '>>' shifts one tab | |
fun! HardTabs(...) | |
let width = (a:0 > 0? a:1 : 8) | |
let &l:tabstop=width | |
let &l:softtabstop=width | |
let &l:shiftwidth=width | |
let &l:expandtab=0 | |
endfun | |
" SoftTabs([softWidth=4, [hardWidth=8]]): Sets up the current buffers so that: | |
" - '\t' is 'hardWidth' wide | |
" - '<tab>' inserts 'softWidth' spaces | |
" - '>>' shifts with 'softWidth' spaces | |
fun! SoftTabs(...) | |
let softWidth = (a:0 > 0? a:1 : 4) | |
let hardWidth = (a:0 > 1? a:2 : 8) | |
let &l:tabstop=hardWidth | |
let &l:softtabstop=softWidth | |
let &l:shiftwidth=softWidth | |
let &l:expandtab=1 | |
endfun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment