Skip to content

Instantly share code, notes, and snippets.

@Shashwat986
Created September 9, 2015 14:04
Show Gist options
  • Save Shashwat986/2da5e2a201637622934f to your computer and use it in GitHub Desktop.
Save Shashwat986/2da5e2a201637622934f to your computer and use it in GitHub Desktop.
My vimrc
syntax on
set number
set ruler
set backspace=indent,eol,start
" Makes vim use the clipboard directly for yank, etc.
set clipboard=unnamed
" Tabs and Indentation
set tabstop=2 expandtab
set shiftwidth=2
set autoindent
" Removes trailing spaces
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
nnoremap <silent> <Leader>rts :call TrimWhiteSpace()<CR>
autocmd FileWritePre * :call TrimWhiteSpace()
autocmd FileAppendPre * :call TrimWhiteSpace()
autocmd FilterWritePre * :call TrimWhiteSpace()
autocmd BufWritePre * :call TrimWhiteSpace()
" Syntax Highlighting of specific files
au BufNewFile,BufRead *.ejs set filetype=html
" Function to move cursor to active window
function! NERDTreeQuit()
redir => buffersoutput
silent buffers
redir END
" 1BufNo 2Mods. 3File 4LineNo
let pattern = '^\s*\(\d\+\)\(.....\) "\(.*\)"\s\+line \(\d\+\)$'
let windowfound = 0
for bline in split(buffersoutput, "\n")
let m = matchlist(bline, pattern)
if (len(m) > 0)
if (m[2] =~ '..a..')
let windowfound = 1
endif
endif
endfor
if (!windowfound)
quitall
endif
endfunction
nmap <leader>N :NERDTree<cr>:wincmd p<cr>:call NERDTreeQuit()<cr>
" Working with buffers
set hidden
nmap <leader>T :enew<cr>
nmap <leader>l :bnext<cr>
nmap <leader>h :bprevious<cr>
nmap <leader>bq :bp <BAR> bd #<cr>
nmap <leader>bQ :bp <BAR> bd! #<cr>
" For the buftabs plugin
set laststatus=2
"let g:buftabs_in_statusline=1
" Highlight all occourrences of word with *. Stay on current word. Highlight removed with <cr>
set hlsearch
nnoremap * *N
nnoremap <cr> :nohlsearch<cr> <cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment