Skip to content

Instantly share code, notes, and snippets.

@prashanthrajagopal
Created December 28, 2014 10:37
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 prashanthrajagopal/daf62295eb9c660f46e0 to your computer and use it in GitHub Desktop.
Save prashanthrajagopal/daf62295eb9c660f46e0 to your computer and use it in GitHub Desktop.
vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" use Vim mode instead of pure Vi, it must be the first instruction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
filetype off " required
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" vundle stuff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set rtp+=~/.vim/bundle/Vundle.vim " set the runtime path to include Vundle and initialize
call vundle#begin() " required
Plugin 'gmarik/Vundle.vim' " let Vundle manage Vundle, required
Plugin 'rking/ag.vim' " https://github.com/rking/ag.vim. A code searching tool similar to ack, with a focus on speed...
Plugin 'kien/ctrlp.vim' " Command-T Successor - F5
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-rake'
Plugin 'tpope/vim-fugitive' " Git
Plugin 'tpope/vim-surround'
Plugin 'msanders/snipmate.vim'
Plugin 'bling/vim-airline'
Plugin 'ervandew/supertab'
Plugin 'mileszs/ack.vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/syntastic'
Plugin 'Raimondi/delimitMate'
Plugin 'mattn/emmet-vim'
Plugin 'vim-scripts/IndexedSearch'
Plugin 'vim-scripts/L9.git'
Plugin 'vim-scripts/matchit.zip'
Plugin 'godlygeek/tabular'
Plugin 'git://gist.github.com/287147.git'
Plugin 'tpope/vim-cucumber'
Plugin 'tpope/vim-haml'
Plugin 'pangloss/vim-javascript'
Plugin 'kchmck/vim-coffee-script'
Plugin 'tpope/vim-endwise'
Plugin 'scrooloose/nerdtree'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'airblade/vim-gitgutter'
call vundle#end() " All of your Plugins must be added before the following line
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => general
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set history=9999 " sets how many lines of history vim has to remember
set timeoutlen=300 " super low delay (works for me)
filetype on " enable file type detection
filetype plugin on " load the plugins for specific file types
filetype indent on " automatically indent code
set autoread " set to auto read when a file is changed from the outside
set clipboard=unnamed
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => vim user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set showcmd " show command in bottom bar
set cursorline " highlight current line
set wildmenu " turn on the wild menu
set wildignore=*.o,*~,*.pyc,*.log,*.exe " ignore compiled files
set encoding=utf-8 " encoding used for displaying file
set ruler " show the cursor position all the time
set showmatch " highlight matching braces
set showmode " show insert/replace/visual mode
set cmdheight=1 " height of the command bar
set hid " a buffer becomes hidden when it is abandoned
set backspace=eol,start,indent " configure backspace so it acts as it should act
set whichwrap+=<,>,h,l
set hlsearch " highlight search results
set ignorecase " do case insensitive search...
set incsearch " do incremental search
set smartcase " ...unless capital letters are used
set lazyredraw " don't redraw while executing macros (good performance config)
set magic " for regular expressions turn magic on
set mat=2 " how many tenths of a second to blink when matching brackets
set noerrorbells " no annoying sound on errors
set novisualbell " no annoying sound on errors
set t_vb= " no annoying sound on errors
set tm=500 " no annoying sound on errors
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => code folding
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set foldenable " enable folding
set foldlevelstart=10 " open most folds by default
set foldnestmax=10 " 10 nested fold max
nnoremap <space> za " space open/closes folds
set foldmethod=indent " fold based on indent level
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => colors and fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable " enable syntax highlighting
set number
colorscheme lucario
syntax enable " enable syntax highlighting
set encoding=utf8 " set utf8 as standard encoding and en_us as the standard language
set ffs=unix,dos,mac " use unix as the standard file type
if has('gui_running') " set extra options when running in gui mode
set guitablabel=%m\ %t
set t_co=256
set guioptions+=e
set clipboard=unnamed
set columns=84 lines=48 " gui window geometry
set number " show line numbers
set guioptions-=t
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nowb
set noswapfile
set confirm " confirm :q in case of unsaved changes
set fileencoding=utf-8 " encoding used when saving file
set nobackup " do not keep the backup~ file
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" edit settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set backspace=indent,eol,start " backspacing over everything in insert mode
set expandtab " fill tabs with spaces
set nojoinspaces " no extra space after '.' when joining lines
set shiftwidth=2 " set indentation depth to 2 columns
set softtabstop=2 " backspacing over 2 spaces
set tabstop=2 " set tabulator length to 2 columns
set wrap " wrap lines
set ai " auto indent
set si " smart indent
""""""""""""""""""""""""""""""
" => visual mode related
""""""""""""""""""""""""""""""
vnoremap <silent> * :call visualselection('f')<cr> " visual mode pressing * or # searches for the current selection
vnoremap <silent> # :call visualselection('b')<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" show invisible stuff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set list
set listchars=tab:▸\ ,eol:¬
"invisible character colors
highlight nontext guifg=#4a4a59
highlight specialkey guifg=#4a4a59
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => misc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
noremap <leader>m mmhmt:%s/<c-v><cr>//ge<cr>'tzt'm " remove the windows ^m - when the encodings gets messed up
map <leader>q :e ~/buffer<cr> " quickly open a buffer for scripbble
map <leader>pp :setlocal paste!<cr> " toggle paste mode on and off
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" automatic commands
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has('autocmd') " file type specific automatic commands
autocmd filetype java setlocal textwidth=132 " tuning textwidth for java code
if has('gui_running')
autocmd filetype java setlocal columns=136
endif
autocmd filetype makefile setlocal noexpandtab " don't replace tabs with spaces when editing makefiles
autocmd filetype tex,xml setlocal indentexpr= " disable automatic code indentation when editing tex and xml files
autocmd bufwritepre * :%s/\(\s*\n\)\{3,}/\r\r/ge" replace groups of empty or whitespaces-only lines with one empty line
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" center view on the search result
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
noremap n nzz
noremap n nzz
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" press f4 to fix indentation in whole file; overwrites marker 'q' position
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
noremap <f4> mqggvg=`qzz
inoremap <f4> <esc>mqggvg=`qzza
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" press f5 to sort selection or paragraph
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
vnoremap <f6> :sort i<cr>
nnoremap <f6> vip:sort i<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" press f8 to turn the search results highlight off
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
noremap <f8> :nohl<cr>
inoremap <f8> <esc>:nohl<cr>a
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => plugin configs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd stdinreadpre * let s:std_in=1 " nerdtree automatically when vim starts up
autocmd vimenter * if argc() == 0 && !exists("s:std_in") | nerdtree | endif " nerdtree automatically when vim starts up
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_next_key='<c-d>'
let g:multi_cursor_prev_key='<c-f>'
let g:multi_cursor_skip_key='<c-x>'
let g:multi_cursor_quit_key='<esc>'
let g:gitgutter_max_signs=5000
let g:gitgutter_sign_column_always=1 "always show the gitgutter column on left
let g:gitgutter_map_keys=0 "gitgutter no key mapings at all
let g:gitgutter_enabled=1
let g:gitgutter_highlight_lines=1
let g:gitgutter_signs=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" my custom bindings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:map <c-a> <home> " map ctrl-a -> start of line
:map <c-e> <end> " map ctrl-e -> end of line
nnoremap <leader>u :gundotoggle<cr> " toggle gundo
nnoremap <leader>ev :vsp $myvimrc<cr> " edit vimrc/zshrc and load vimrc bindings
nnoremap <leader>ez :vsp ~/.zshrc<cr>
nnoremap <leader>sv :source $myvimrc<cr>
nnoremap <leader>s :mksession<cr> " save session
nnoremap <f3> :ag " open ag.vim
map <c-n> :nerdtreetoggle<cr> " ctrl-n toggle nerd tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment