Skip to content

Instantly share code, notes, and snippets.

@agnivade
Last active August 29, 2015 14:07
Show Gist options
  • Save agnivade/5ffefb523c5ff1fb45c1 to your computer and use it in GitHub Desktop.
Save agnivade/5ffefb523c5ff1fb45c1 to your computer and use it in GitHub Desktop.
my vimrc file
set number
set tabstop=2
set expandtab
set smartindent
set autoindent
set smarttab
set shiftwidth=2
set ignorecase
set incsearch
set hls
set bg=dark
set textwidth=80
set tags=./tags,./../tags,./../../tags,./../../../tags,tags
set foldmethod=indent
set foldnestmax=0
syntax enable
" Comment highlighting to teal
highlight Comment ctermfg=6
" Set the backspace so you can delete just more than the current write
set bs=2
" Black magic to make it jump to the last position int he file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
" to show the current column number in the bottom right
set ruler
" highlights the line that crosses the 80 column width limit.
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%800v.\+/
" Indent Python in the Google way.
setlocal indentexpr=GetGooglePythonIndent(v:lnum)
let s:maxoff = 50 " maximum number of lines to look backwards.
function GetGooglePythonIndent(lnum)
" Indent inside parens.
" Align with the open paren unless it is at the end of the line.
" E.g.
" open_paren_not_at_EOL(100,
" (200,
" 300),
" 400)
" open_paren_at_EOL(
" 100, 200, 300, 400)
call cursor(a:lnum, 1)
let [par_line, par_col] = searchpairpos('(\|{\|\[', '', ')\|}\|\]', 'bW',
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
\ . " =~ '\\(Comment\\|String\\)$'")
if par_line > 0
call cursor(par_line, 1)
if par_col != col("$") - 1
return par_col
endif
endif
" Delegate the rest to the original function.
return GetPythonIndent(a:lnum)
endfunction
let pyindent_nested_paren="&sw*2"
let pyindent_open_paren="&sw*2"
" To automatically remove the trailing whitespaces from the code.
autocmd FileType c,cpp,java,json,php,py,h autocmd BufWritePre <buffer> :%s/\s\+$//e
autocmd BufWritePre *.c :%s/\s\+$//e
autocmd BufWritePre *.h :%s/\s\+$//e
autocmd BufWritePre *.cpp :%s/\s\+$//e
autocmd BufWritePre *.json :%s/\s\+$//e
autocmd BufWritePre *.py :%s/\s\+$//e
augroup filetype
au! BufRead,BufNewFile *.proto setfiletype proto
augroup end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment