Skip to content

Instantly share code, notes, and snippets.

@iamrahulroy
Last active June 26, 2016 14:34
Show Gist options
  • Save iamrahulroy/91ffadbeb412c38c9d66b8b669c90dcd to your computer and use it in GitHub Desktop.
Save iamrahulroy/91ffadbeb412c38c9d66b8b669c90dcd to your computer and use it in GitHub Desktop.
"--------------- Standard settings ------------------
set nocompatible " No compatibility with legacy Vi
set tabstop=2 " a tab is two spaces
set smarttab " Tab should always be smart
set softtabstop=2 " when hitting <BS>, pretend like a tab is removed, even if spaces
set expandtab " expand tabs by default (overloadable per file type later)
set shiftwidth=2 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set tags=tags " for ctags - require more setup
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
set autowrite " Save on buffer switch - Automatically save before :next, :make etc.
set autoread " Automatically reread changed files without asking me anything
set backspace=indent,eol,start " Enable backspace
set noswapfile " Don't use swapfile
set encoding=utf-8 " Set default encoding
set undofile " Save undo's after file closes
set undodir=$HOME/.vim/undo " where to save undo histories
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
"--------------- UI Settings ------------------
color solarized
set t_Co=256 " Set terminal colour to 256
set showcmd " show command in bottom bar
set cursorcolumn " Highlight the current column
set colorcolumn=80 " Highlight 80th column
set showmatch " Show matching bracket
set number " always show line numbers
set visualbell " don't beep
set noerrorbells " fucking don't beep
set so=7 " Set 7 lines to the cursor - when moving vertically using j/k
set incsearch " Shows the match while typing
set hlsearch " Highlight found searches
set lazyredraw " Don't redraw while executing macros (good performance config)
set wrap " Wrap lines
set gfn=Monaco:h14 " for MacVim
highlight Search cterm=underline
"--------------- Let mappings ------------------
let mapleader = ',' " Better leader key
"-------------------- Mappings ------------
nmap <Leader>ev :tabedit ~/.vimrc.local<cr> " Quickly edit vimrc file
nmap <Leader>w :w!<cr> " Quickly write current file
imap jj <ESC> " ESC is far far away jj is much better
nmap pn o<ESC>p " Paste on new Line from the cursor
nmap <Leader>bd :bd<cr> " Close buffer
nmap <Leader>q :q<cr> " Quit without bang
nmap <leader>ba :1,1000 bd!<cr> " Close all the buffers
"-------------------- Plugin Related Mappings ------------
nmap <C-b> :NERDTreeToggle<cr> " Toggle NERDTreeToggle quickly
"----------------Vim Super Enhancements------------------
later 9999999d " Remember history for 9999999 days. Great for redo, undo etc.
"--------------------Auto-Commands --------------
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc source % " Auto source .vimrc on changes
autocmd BufLeave,FocusLost * silent! wall " Auto save on buffer leave & focus lost
augroup END
"-------------------- sublime like settings ------------
" it wont hurt to mimic sublime for now.
" Adding comment on the same line inserts the comment. Investigate.
imap <d-cr> <esc>o
" open sidebar with cmd+k
map <d-k> :nerdtreetabstoggle<cr>
map <d-p> :ctrlp
imap <c-s-cr> <esc>o
imap <d-k> <ESC>:call feedkeys( line('.')==1 ? '' : 'ddkP' )<cr>
imap <d-j> <ESC>ddp
" switch between tabs with cmd+1, cmd+2,..."
map <d-1> 1gt
map <d-2> 2gt
map <d-3> 3gt
map <d-4> 4gt
map <d-5> 5gt
map <d-6> 6gt
map <d-7> 7gt
map <d-8> 8gt
map <d-9> 9gt
" insert mode
imap <D-1> <esc>1gt
imap <D-2> <esc>2gt
imap <D-3> <esc>3gt
imap <D-4> <esc>4gt
imap <D-5> <esc>5gt
imap <D-6> <esc>6gt
imap <D-7> <esc>7gt
imap <D-8> <esc>8gt
imap <D-9> <esc>9gt
" Notes and Tips
" zz to center current line.
" ,,w to invoke easymotion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment