From b9098890e3f2a2545496fc738dc9377c403b773a Mon Sep 17 00:00:00 2001 From: nirenjan Date: Fri, 12 Apr 2013 15:10:38 -0700 Subject: [PATCH] Create tab-expand plugin for vim This moves from a one-size-fits-all approach for tab expansion to dictating a default expansion scheme and a per filetype scheme. The current plugin has custom schemes for Ruby and Makefiles. --- vim/plugin/tab-expand.vim | 36 ++++++++++++++++++++++++++++++++++++ vimrc | 5 +---- 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 vim/plugin/tab-expand.vim diff --git a/vim/plugin/tab-expand.vim b/vim/plugin/tab-expand.vim new file mode 100644 index 0000000..8190eba --- /dev/null +++ b/vim/plugin/tab-expand.vim @@ -0,0 +1,36 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Tabs plugin for vim +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +" This plugin reconfigures the tab key expansion depending on the language +" of the file being edited. +" +" USAGE: +" -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a +" 'plugin' directory in some other directory that is in your +" 'runtimepath'. +" +" -- vim 5: Stick this file somewhere and 'source cscope.vim' it from +" your ~/.vimrc file (or cut and paste it into your .vimrc). +" +" NOTE: +" Make sure to add individual preferences for the language of your choice. +" +" Nirenjan Krishnan nirenjan@gmail.com 2013/04/12 +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Default +" Tabstop = 4 +" Soft Tabstop = 4 +" Shiftwidth = 4 +" Expand tabs +autocmd FileType * set ts=4 sts=4 sw=4 et + +" Ruby +" Tabstop = 2, expand +autocmd FileType ruby setlocal ts=2 sts=2 sw=2 et + +" Make +" Tabstop = 4, No expand tab +autocmd FileType make setlocal ts=4 sts=4 sw=4 noet + diff --git a/vimrc b/vimrc index 76eb636..a0ce944 100644 --- a/vimrc +++ b/vimrc @@ -6,10 +6,7 @@ call pathogen#infect() call pathogen#helptags() " Editing options -" No tabs, shiftwidth 4, tabstop 4 -set shiftwidth=4 -set tabstop=4 -set expandtab +" These are now handled by the tab-expand plugin " Automatic indentation of code blocks set autoindent