From 5f9e0aa4e524097c5e2428b96c21c4f92a2a3b9f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 26 May 2014 16:42:27 -0400 Subject: Create custom vim plugin for Stab command Take the `Stab` command from my vimrc and put it in a custom plugin. This will keep my vimrc cleaner and since the the functions are autoloaded it may ever so slightly improve performance. --- bundle/set-tab/autoload/set_tab.vim | 27 +++++++++++++++++++++++++++ bundle/set-tab/plugin/set_tab.vim | 3 +++ 2 files changed, 30 insertions(+) create mode 100644 bundle/set-tab/autoload/set_tab.vim create mode 100644 bundle/set-tab/plugin/set_tab.vim (limited to 'bundle') diff --git a/bundle/set-tab/autoload/set_tab.vim b/bundle/set-tab/autoload/set_tab.vim new file mode 100644 index 0000000..c3bcec1 --- /dev/null +++ b/bundle/set-tab/autoload/set_tab.vim @@ -0,0 +1,27 @@ +" Set tabstop, softtabstop and shiftwidth to the same value +" http://vimcasts.org/episodes/tabs-and-spaces/ +function! set_tab#Stab() + let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ') + if l:tabstop > 0 + let &l:sts = l:tabstop + let &l:ts = l:tabstop + let &l:sw = l:tabstop + endif + call s:SummarizeTabs() +endfunction + +function! s:SummarizeTabs() + try + echohl ModeMsg + echon 'tabstop='.&l:ts + echon ' shiftwidth='.&l:sw + echon ' softtabstop='.&l:sts + if &l:et + echon ' expandtab' + else + echon ' noexpandtab' + endif + finally + echohl None + endtry +endfunction diff --git a/bundle/set-tab/plugin/set_tab.vim b/bundle/set-tab/plugin/set_tab.vim new file mode 100644 index 0000000..4b58fa3 --- /dev/null +++ b/bundle/set-tab/plugin/set_tab.vim @@ -0,0 +1,3 @@ +" Set tabstop, softtabstop and shiftwidth to the same value +" http://vimcasts.org/episodes/tabs-and-spaces/ +command! -nargs=* Stab call set_tab#Stab() -- cgit v1.2.3