Skip to content

Instantly share code, notes, and snippets.

@nzajt
Created May 2, 2014 23:14
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 nzajt/edc5014324762642e6ef to your computer and use it in GitHub Desktop.
Save nzajt/edc5014324762642e6ef to your computer and use it in GitHub Desktop.
My Vimrc File
filetype off
call pathogen#incubate()
filetype plugin indent on
set encoding=utf-8
" Maps
nmap nt :NERDTreeToggle<return>
nmap Nt :NERDTreeToggle<return>
imap <c-w> <esc>:w<return>
nmap <silent> cs /asdfasdfasdf<return>i
nmap ww <c-w><c-w>
nmap ff <C-S-W><bar>
nmap f= <C-S-W>=
nmap w= <c-w><c-w><C-S-W>=
" Commenting blocks of code.
autocmd FileType c,cpp,java,scala let b:comment_leader = '// '
autocmd FileType sh,ruby,python let b:comment_leader = '# '
autocmd FileType conf,fstab let b:comment_leader = '# '
autocmd FileType tex let b:comment_leader = '% '
autocmd FileType mail let b:comment_leader = '> '
autocmd FileType vim let b:comment_leader = '" '
nmap <silent> ,cc :<C-B>silent<C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
nmap <silent> ,CC :<C-B>silent<C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>
" Spaces for Tabs
set tabstop=2
set shiftwidth=2
set expandtab
set nocompatible
set modelines=0
set autoread
set nostartofline
set showmode
set showcmd
set hlsearch
set showmatch
set matchtime=1
set number
set noet sts=0 sw=2 ts=2
set splitright
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
autocmd BufNewFile,BufRead *.thor set filetype=ruby
autocmd BufNewFile,BufRead Thorfile set filetype=ruby
autocmd BufWritePre *.py,*.js,*.rb,*.coffee,*.haml,*.erb :call <SID>StripTrailingWhitespaces()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MULTIPURPOSE TAB KEY
" " Indent if we're at the beginning of a line. Else, do completion.
" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
" Indent Plugin
let g:indent_guides_auto_colors = 0
let g:indent_guides_start_level = 3
let g:indent_guides_guide_size = 1
colorscheme default
autocmd! VimEnter,Colorscheme * hi IndentGuidesOdd ctermbg=236 guibg=#303030 | hi IndentGuidesEven ctermbg=239 guibg=#505050
autocmd BufRead * IndentGuidesEnable
" OSX clipboard
if $TMUX == ''
set clipboard=unnamed
end
" Select Copy like iterm
set go+=a
" Mouse in Terminal
set mousemodel=extend
set mouse=a
set mousehide
" No word wrap for CSV
autocmd BufRead *.csv,*.csv*,<csv> set nowrap
" Mouse scroll in vim
map <M-Esc>[62~ <ScrollWheelUp>
map <M-Esc>[63~ <ScrollWheelDown>
map <M-Esc>[64~ <S-ScrollWheelUp>
map <M-Esc>[65~ <S-ScrollWheelDown>
map! <M-Esc>[62~ <ScrollWheelUp>
map! <M-Esc>[63~ <ScrollWheelDown>
map! <M-Esc>[64~ <S-ScrollWheelUp>
map! <M-Esc>[65~ <S-ScrollWheelDown>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment