Skip to content

Instantly share code, notes, and snippets.

@siddharthvipul siddharthvipul/vimrc
Last active Nov 2, 2018

What would you like to do?
my vimrc file
" don't make vim compatible with vi
set nocompatible
" make vim try to detect file types and load plugins for them
filetype on
filetype plugin on
filetype indent on
" encoding is utf-8
set encoding=utf-8
set fileencoding=utf-8
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
" The bundles you install will be listed here
Plugin 'gmarik/Vundle.vim'
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
Plugin 'tpope/vim-fugitive'
Plugin 'scrooloose/nerdtree'
Plugin 'Valloric/YouCompleteMe'
Plugin 'bling/vim-airline'
Plugin 'bling/vim-bufferline'
Plugin 'flazz/vim-colorschemes'
Plugin 'myusuf3/numbers.vim'
Plugin 'zenorocha/dracula-theme', {'rtp': 'vim/'}
Plugin 'scrooloose/nerdcommenter'
Plugin 'Yggdroot/indentLine'
Plugin 'airblade/vim-gitgutter'
Plugin 'christoomey/vim-system-copy' " cpi'/cpiw/cv
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'pearofducks/ansible-vim'
" Plugin 'wincent/Command-T'
" Plugin 'scrooloose/syntastic'
" theme
" colorscheme 256-jungle
" colorscheme BlackSea
colorscheme CandyPaper
" React based
" Plugin 'pangloss/vim-javascript'
" Plugin 'mxw/vim-jsx'
call vundle#end()
filetype plugin indent on
let mapleader = ","
set et
set ai
set sw=4
set ts=4
set ruler
set si
set nu
set is
set ic
set sm
set sta
set backspace=indent,eol,start
set hlsearch
set nobackup
set nowritebackup
set path+=**
set wildmenu
set incsearch
syn on
"" Highlight White spaces with Red
highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set autowrite " Automatically save before commands like :next and :make
set hidden " Hide buffers when they are abandoned
set mouse=a " Enable mouse usage (all modes)
set expandtab " Convert tab to spaces
set tw=79 " Automatic word wrapping at 79
set wrap " Set wrapping of words
set linebreak " Only break line when I press Enter
set nolist " List disables line break
set hlsearch " Highlight Search
set makeprg=g++\ % " Configuration for :make in vim
set smarttab " Makes tabs insert "indents" at the beginning of the line
set colorcolumn=80 " Set the color column to 80 characters
highlight ColorColumn ctermbg=8
set pastetoggle=<F4> " Toggle paste
set noswapfile " prevent vim from creating swp file
set autochdir " change buffer dir as per file location
set laststatus=2 " Always show status line
set t_Co=256 " Use 256 colours (Use this setting only if your terminal supports 256 colours)
" Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
set splitbelow
set splitright
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected file type.
if has("autocmd")
filetype plugin indent on
" file-based configuration
autocmd FileType html :setlocal sw=2 ts=2 sts=2
autocmd Filetype javascript setlocal ts=2 sw=2 expandtab
autocmd Filetype json setlocal ts=2 sw=2 expandtab
autocmd Filetype python setlocal ts=4 sw=4 expandtab
autocmd Filetype yml setlocal ts=2 sw=2 expandtab
autocmd Filetype yaml setlocal ts=2 sw=2 expandtab
" some commands from vim
command! -nargs=* -complete=file Gcheckout :!git checkout %
command! -nargs=* -complete=file GDiff :!git diff %
" command! -nargs=* -complete=file Ar :!sudo /etc/init.d/apache2 restart
command! -nargs=* -complete=file Rs :!export SRCPATH=%:p:h && export DESTPATH=${SRCPATH/static_media/static} && stylus % && mv %:r.css $DESTPATH
command! -nargs=* -complete=file Cp :!export SRCPATH=%:p:h && export DESTPATH=${SRCPATH/static_media/static} && cp % $DESTPATH
" Sort the current paragraph.
" Useful for sorting includes, imports, namespaces and other declaration groups.
" With this enabled, you can just insert your statement anywhere and just press ,s
nmap ,s {jv}k:sort<CR>
nmap \o :set paste!<CR> " Toggles paste mode
nmap \l :setlocal number!<CR> " Toggles line numbers
nmap \q :nohlsearch<CR> " Clear highlight search
hi Search cterm=NONE ctermfg=black ctermbg=blue "search color
nmap \e :NERDTreeToggle<CR> " Toggle NerdTree
vmap \cc :s/^/#/<cr>
vmap \co :s/^#//<cr>
nmap <c-s> :w<CR>
imap <c-s> <Esc>:w<CR>
au FileType make set noet
" Copy to clipboards * and +
vmap "+y :!xclip -f -selection clip
map "+p :r!xclip -o -sel clip
" Readmes autowrap text:
autocmd BufRead,BufNewFile *.md,*.tex set tw=79
" Get line, word and character counts with F3:
map <F3> :!wc <C-R>%<CR>
" Spell-check set to F6:
map <F6> :setlocal spell! spelllang=en_us<CR>
noremap <Leader>y "*y
noremap <Leader>p "*p
noremap <Leader>Y "+y
noremap <Leader>P "+p
" Shortcutting split navigation, saving a key press:
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" C-T for new tab
nnoremap <C-t> :tabnew<cr>
" Plugins Installations and Configurations
" Vim airline
let g:airline#extensions#tabline#enabled = 1
" Syntastic
" let g:syntastic_check_on_open=1
" let g:syntastic_enable_signs=1
" Ctrl-P Buffers
set runtimepath^=~/.vim/bundle/ctrlp.vim
nmap ; :CtrlPBuffer<CR>
nmap <C-e> :e#<CR>
nmap <C-n> :bnext<CR>
nmap <C-b> :bprev<CR>
" Vim Powerline configurations
set rtp+=/usr/local/lib/python2.7/dist-packages/powerline/bindings/vim/
" Markdown made easy
autocmd Filetype markdown,rmd map <leader>w yiWi[<esc>Ea](<esc>pa)
" line break
autocmd Filetype markdown,rmd inoremap ,n ---<Enter><Enter>
" bold
autocmd Filetype markdown,rmd inoremap ,b ****<++><Esc>F*hi
" strike through
autocmd Filetype markdown,rmd inoremap ,s ~~~~<++><Esc>F~hi
" emphasis/italic
autocmd Filetype markdown,rmd inoremap ,e **<++><Esc>F*i
" title header
autocmd Filetype markdown,rmd inoremap ,h ====<Space><++><Esc>F=hi
" image link
autocmd Filetype markdown,rmd inoremap ,i ![](<++>)<++><Esc>F[a
" url link
autocmd Filetype markdown,rmd inoremap ,a [](<++>)<++><Esc>F[a
" header 1
autocmd Filetype markdown,rmd inoremap ,1 #<Space><Enter><Esc>kA
" header 2
autocmd Filetype markdown,rmd inoremap ,2 ##<Space><Enter><Esc>kA
" header 3
autocmd Filetype markdown,rmd inoremap ,3 ###<Space><Enter><Esc>kA
" line
autocmd Filetype markdown,rmd inoremap ,l --------<Enter>
autocmd Filetype markdown,rmd inoremap ,r ```{r}<CR>```<CR><CR><esc>2kO
autocmd Filetype markdown,rmd inoremap ,p ```{python}<CR>```<CR><CR><esc>2kO
autocmd Filetype markdown,rmd inoremap ,c ```<cr>```<cr><cr><esc>2kO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.