Create a gist now

Instantly share code, notes, and snippets.

@neotohin /vimrc
Last active Aug 29, 2015

What would you like to do?
My VIM configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Setting Vundle Bundles
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
"filetype off
function! LoadVundle()
let vundle_installed=filereadable(expand('~/.vim/bundle/vundle/README.md'))
if vundle_installed == 0
echo "Creating backups directory..."
silent !mkdir -p ~/.vim/backups
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
endif
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Bundle definitions
Bundle 'scrooloose/syntastic'
Bundle 'kchmck/vim-coffee-script'
Bundle 'slim-template/vim-slim'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-haml'
"Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-repeat'
Bundle 'vim-ruby/vim-ruby'
Bundle 'pangloss/vim-javascript'
Bundle 'digitaltoad/vim-jade'
Bundle 'majutsushi/tagbar'
Bundle 'tomtom/tcomment_vim'
Bundle 'mileszs/ack.vim'
Bundle 'scrooloose/nerdtree'
Bundle 'chriskempson/base16-vim'
Bundle 'chriskempson/vim-tomorrow-theme'
Bundle 'altercation/vim-colors-solarized'
Bundle 'guns/vim-clojure-static'
Bundle 'elzr/vim-json'
Bundle 'nono/vim-handlebars'
Bundle 'rking/ag.vim'
Bundle 'kien/ctrlp.vim'
"Bundle 'SuperTab'
Bundle 'Tabular'
Bundle 'airblade/vim-gitgutter'
"Bundle 'jeetsukumaran/vim-buffergator'
"Amzad List
"Bundle 'wincent/Command-T'
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
Bundle "garbas/vim-snipmate"
Bundle "honza/vim-snippets"
Bundle "tanarurkerem/drupal-snippets"
Bundle "bling/vim-airline"
Bundle "tpope/vim-unimpaired"
Bundle "terryma/vim-multiple-cursors"
Bundle "fholgado/minibufexpl.vim"
Bundle "chrisbra/NrrwRgn"
Bundle "vim-scripts/Gundo"
if vundle_installed==0
echo vundle_installed
echo "Vundle Installed, now Installing Bundles..."
echo ""
:BundleInstall
endif
filetype plugin indent on
endfunction
call LoadVundle()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set expandtab
set shiftwidth=2
set tabstop=2
set smarttab
set lbr
set tw=500
set ai "Auto indent
set si "Smart indet
set wrap "Wrap lines
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => GENERAL SETTINGS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader="," " Changing leader \ to , character for better usage
set history=700 " Sets how many lines of history VIM has to remember
set undolevels=1000 " Increasing undo limits
filetype plugin on " Enable filetype plugin
filetype indent on
set autoread " Set to auto read when a file is changed from the outside
syntax on "Enable syntax hl
" set mouse=a
set number
set ruler
set title
set nobackup
set noswapfile
set hidden "Change buffer - without saving
set laststatus=2
set cmdheight=1 "The commandbar height
" Tab completion make sense
set wildmode=longest:full
set wildmenu
" Set backspace config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set hlsearch "Highlight search things
set incsearch "Make search act like search in modern browsers
set showmatch "Show matching bracets when text indicator is over them
" Query highlight in string
let php_sql_query = 1
let php_parent_error_close = 1
let php_noShortTags = 1
let php_htmlInStrings = 1
set mat=2 "How many tenths of a second to blink
"folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=1 "this is just what i use
"Auto Change directory
lcd %:p:h
syntax enable "Enable syntax hl
set encoding=utf8
set ffs=unix,dos,mac "Default file types
"Vim can highlight whitespaces for you in a convenient way
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:.
autocmd filetype html,xml set listchars-=tab:>.
" Use modeline overrides
set modeline
set modelines=10
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" This section is drupal file extension detection
" For snipmate
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup drupal
autocmd BufRead,BufNewFile *.module set filetype=php.drupal
autocmd BufRead,BufNewFile *.theme set filetype=php.drupal
autocmd BufRead,BufNewFile *.inc set filetype=php.drupal
autocmd BufRead,BufNewFile *.install set filetype=php.drupal
autocmd BufRead,BufNewFile *.info set filetype=php.drupal
autocmd BufRead,BufNewFile *.engine set filetype=php.drupal
autocmd BufRead,BufNewFile *.profile set filetype=php.drupal
autocmd BufRead,BufNewFile *.test set filetype=php.drupal
augroup END
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Nerdtree Configuration
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>n :NERDTreeToggle<CR>
map <Leader>s :w<CR>
map <Leader>x :q<CR>
map <Leader>q :qa<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Few common mistakes that i do while programming
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
abbr funciton function
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set font according to system
set gfn=Menlo:h14
set shell=/bin/bash
set t_Co=16
set background=dark
colors slate
colorscheme solarized
""""""""""""""""""""""""""""""
" => Minibuffer plugin
""""""""""""""""""""""""""""""
let g:miniBufExplModSelTarget = 1
let g:miniBufExplorerMoreThanOne = 1
let g:miniBufExplModSelTarget = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplVSplit = 30
let g:miniBufExplSplitBelow=1
autocmd BufRead,BufNew :call UMiniBufExplorer
map <leader>u :MBEToggle<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Key Mappings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Parenthesis/bracket expanding
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>
" Map auto complete of (, ", ', [
inoremap $1 ()<esc>i
inoremap $2 []<esc>i
inoremap $3 {}<esc>i
inoremap $4 {<esc>o}<esc>O
inoremap $q ''<esc>i
inoremap $e ""<esc>i
inoremap $t <><esc>i
"Alt+leftarrow will go one window left, etc.
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
" Key mappings
nnoremap <leader>ft Vatzf
nnoremap <leader>w :w!<cr>
"Beter Tab Operation
nnoremap <leader>tn :tabnew<cr>
nnoremap <leader>tc :tabclose<cr>
nnoremap <leader>te :tabedit
nnoremap <leader>[t :tabnext<cr>
nnoremap <leader>]t :tabprev<cr>
" Split Window Switching
nnoremap ,h <C-W>h
nnoremap ,j <C-W>j
nnoremap ,k <C-W>k
nnoremap ,l <C-W>l
nnoremap ,H <C-W>H
nnoremap ,J <C-W>J
nnoremap ,K <C-W>K
nnoremap ,L <C-W>L
nnoremap <Leader>] :noh <CR>
nnoremap <Leader>p :set paste<CR>
nnoremap <Leader>o :set nopaste<CR>
nnoremap <Leader>bn :bn<CR>
nnoremap <Leader>bp :bp<CR>
nnoremap <Leader>bd :bd<CR>
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
"Toggle Paste Mode easily
set pastetoggle=<F2>
" it strips off two full keystrokes from almost every Vim command. For quit just type ;q
nnoremap ; :
"If you opened a readonly file like /etc/hosts press w!! solve :)
cmap w!! w !sudo tee % >/dev/null
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Custom Functions
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Toggle Folding
function! ToggleFolding()
let curr_fold=&foldmethod
let en='off'
if curr_fold == 'syntax'
:setlocal foldmethod=manual
else
let en='on'
:setlocal foldmethod=syntax
endif
echo "Toggled folding ".en
endfunction
map <Leader>tf :call ToggleFolding()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Airline Plugin Settings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Credit :)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"github.com/machuga/dotfiles
"http://nvie.com/posts/how-i-boosted-my-vim/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment