Skip to content

Instantly share code, notes, and snippets.

@kartikchauhan
Last active November 22, 2019 08:17
Show Gist options
  • Save kartikchauhan/34dcb98604eaa8c47abd11fdfe7b50f1 to your computer and use it in GitHub Desktop.
Save kartikchauhan/34dcb98604eaa8c47abd11fdfe7b50f1 to your computer and use it in GitHub Desktop.
Use this .vimrc file to boost your productivity.
" no vi compat
set nocompatible
" show line numbers
set number
" set backspace
set backspace=indent,eol,start
" automatically use the system clipboard for copy and paste.
set clipboard=unnamedplus
" go to the middle of the line using gm
nnoremap gm :call cursor(0, len(getline('.'))/2)<CR>
" ++++++++ pathogen plugins begin ++++++++
" execute pathogen#infect()
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_auto_loc_list = 1
"let g:syntastic_check_on_open = 1
"let g:syntastic_check_on_wq = 0
" ++++++++ pathogen plugins end ++++++++
" filetype func off
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
"open vimrc in three key strokes"
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" initialize vundle
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" start- all plugins below
Plugin 'ervandew/supertab'
" Plugin 'Valloric/YouCompleteMe'
Plugin 'altercation/vim-colors-solarized'
Plugin 'VundleVim/Vundle.vim'
Plugin 'mattn/emmet-vim'
Plugin 'morhetz/gruvbox'
Plugin 'itchyny/lightline.vim'
" Plugin 'scrooloose/nerdtree.git'
Plugin 'davidhalter/jedi-vim'
Plugin 'pangloss/vim-javascript'
Plugin 'groenewege/vim-less'
Plugin 'taglist.vim'
Plugin 'elzr/vim-json'
Plugin 'airblade/vim-gitgutter' " http://vimawesome.com/plugin/vim-gutter
Plugin 'wincent/command-t' " fast buffer browser
Plugin 'scrooloose/nerdcommenter'
Plugin 'easymotion/vim-easymotion'
Plugin 'tpope/vim-unimpaired'
Plugin 'Align'
Plugin 'scrooloose/nerdtree'
Plugin 'ctrlpvim/ctrlp.vim'
" Solidity Plugin
Plugin 'tomlion/vim-solidity'
" stop - all plugins above
call vundle#end()
" NerdTree mappings
map <C-m> :NERDTreeToggle<CR>
let NERDTreeQuitOnOpen = 0
map <C-Right> :tabn<CR>
map <C-Left> :tabp<CR>
map <C-n> :tabnew<CR>
" Plugin CtrlP bindings
let g:ctrlp_map = '<c-o>'
let g:ctrlp_cmd = 'CtrlPMRU'
let g:ctrlp_match_window = 'top'
" Trigger CtrlP on pressing Ctrl-o in insert mode
inoremap <C-o> <Esc>:CtrlP<CR>
fun! ChooseBuf()
redir => buffers
silent ls
redir end
echo l:buffers
let l:choice = input('Which one: ')
execute ':edit +' . l:choice . 'buf'
endfun
command! ChooseBuf call ChooseBuf()
nnoremap <Leader>q :call ChooseBuf()<CR>
"Key binding
"vmap <C-j> <Plug>MoveBlockDown
"vmap <C-k> <Plug>MoveBlockUp
"nmap <A-j> <Plug>MoveLineDown
"nmap <A-k> <Plug>MoveLineUp
"
"map <C-n> :NERDTreeToggle<CR>
"" Open NERDTree automatically when a file opens
"" autocmd vimenter * NERDTree
"
"" Close NERDTree when there's only NERDTree window opened
"autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"
" NERDTress File highlighting
" function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
" exec 'autocmd Filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
" exec 'autocmd Filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
" endfunction
"
" call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515')
" call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#151515')
" call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#151515')
" call NERDTreeHighlightFile('yaml', 'yellow', 'none', 'yellow', '#151515')
" call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#151515')
" call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#151515')
" call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#151515')
" call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#151515')
" call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#151515')
" call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#151515')
" call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#151515')
" call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#151515')
" call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#151515')
" call NERDTreeHighlightFile("go", 'yellow', 'none', 'yellow', '#151515')
" hi Comment ctermfg=yellow
syntax enable
set background=light
" colorscheme solarized
" set background=dark
" set highlight Comment guifg=#FF4500
" set highlight Comment ctermfg=yellow
" filetype func on
" to constantly see filename in vim
set laststatus=2
" ctags mapping
nnoremap <leader>. :CtrlOTag<cr>
" Open Vim from the same place you left off at
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
@kartikchauhan
Copy link
Author

kartikchauhan commented Oct 11, 2019

Before using any plugin, you'll first need to setup VundleVim.

Create /home/$USER/.vim/bundle

mkdir -p /home/$USER/.vim/bundle

Clone the git repository into bundle directory:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Now create a .vimrc file if already not there:

touch /home/$USER/.vimrc

Copy the lines in the above file into your .vimrc
Now either run vim +PluginInstall +qall on the terminal or :PluginInstall inside vim.

You're good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment