Skip to content

Instantly share code, notes, and snippets.

@sfrdmn
Last active December 19, 2015 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfrdmn/6012090 to your computer and use it in GitHub Desktop.
Save sfrdmn/6012090 to your computer and use it in GitHub Desktop.
vim config for use with vundle
syntax on
set ts=2
set shiftwidth=2
set autoindent
set smartindent
set expandtab
set ruler
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
command Ni set noautoindent nosmartindent
command Yi set autoindent smartindent
au BufRead,BufNewFile *.mustache set filetype=html
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile [Mm]akefile set noexpandtab
au BufRead,BufNewFile (*.coffee|*.cson) set noexpandtab
au BufRead,BufNewFile *.json set filetype=javascript
au BufRead,BufNewFile *.php set ts=4
au BufRead,BufNewFile *.php set shiftwidth=4
function! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
function! Comment()
let ext = tolower(expand('%:e'))
if ext == 'rb' || ext == 'sh' || ext == 'py'
silent s/^/\#/
elseif ext == 'js' || ext == 'php' || ext == 'c'
silent s:^:\/\/:g
elseif ext == 'vim'
silent s:^:\":g
endif
endfunction
function! Uncomment()
let ext = tolower(expand('%:e'))
if ext == 'php' || ext == 'rb' || ext == 'sh' || ext == 'py'
silent s/^\#//
elseif ext == 'js'
silent s:^\/\/::g
elseif ext == 'vim'
silent s:^\"::g
endif
endfunction
map 0 ^
map <C-a> :call Comment()<CR>
map <C-b> :call Uncomment()<CR>
map <C-k> :call DeleteTrailingWS()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment