Skip to content

Instantly share code, notes, and snippets.

@tiagoamaro
Last active December 22, 2015 19:19
Show Gist options
  • Save tiagoamaro/6519220 to your computer and use it in GitHub Desktop.
Save tiagoamaro/6519220 to your computer and use it in GitHub Desktop.
.vimrc file
" ------------------------------------------------------------------------------
" FILE: .vimrc
" DESCRIPTION: Vim configuration file. Strongly based on vasconcelloslf .vimrc :)
" AUTHOR: Tiago Amaro (github.com/tiagoamaro)
" ------------------------------------------------------------------------------
set rtp+=~/.vim/bundle/vundle/
" Vundle
set nocompatible
filetype off
" let Vundle manage Vundle
call vundle#rc()
" required!
Bundle 'gmarik/vundle'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'bling/vim-airline'
Bundle 'tpope/vim-rails.git'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-fugitive'
Bundle 'davidkariuki/sexy-railscasts-256-theme'
Bundle 'airblade/vim-gitgutter'
Bundle 'kchmck/vim-coffee-script'
Bundle 'terryma/vim-multiple-cursors'
Bundle 'tomtom/tcomment_vim'
Bundle 'mattn/emmet-vim'
Bundle 'scrooloose/syntastic'
Bundle 'majutsushi/tagbar'
Bundle 'scrooloose/nerdtree'
Bundle 'EasyGrep'
Bundle 'kien/ctrlp.vim'
Bundle 'ShowTrailingWhitespace'
Bundle 'majutsushi/tagbar'
Bundle 'AutoComplPop'
" General Settings
set undolevels=1000 " Large undo levels.
set undofile " Save undo tree.
set undodir=/tmp " Undo tree directory.
set history=700 " Size of command history.
set encoding=utf8 " Always use unicode.
set autoread " set to autoread when a file is changed from the outside
set backspace=indent,eol,start " Fix backspace.
set nobackup " Disable backups.
set nowritebackup
set noswapfile
set notimeout " Fix lag in iTerm.
set ttimeout
set timeoutlen=50
set nomodeline
set selection=inclusive " Select to the end of line.
set spelllang=en_au " Set spell check language.
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Whitespaces
set tabstop=2 " Set tab to equal 4 spaces.
set softtabstop=2 " Set soft tabs equal to 4 spaces.
set shiftwidth=2 " Set auto indent spacing.
set expandtab
" Indentation
set si "Smart indent
set wrap "Wrap lines
" Search and Replace
set incsearch " Show partial matches as search is entered.
set hlsearch " Highlight search patterns.
set ignorecase " Enable case insensitive search.
set smartcase " Disable case insensitivity if mixed case.
set wrapscan " Wrap to top of buffer when searching.
set gdefault " Make search and replace global by default.
" Presentation
set showmatch " Show matching parenthesis.
set ttyfast " Fast scrolling when on a decent connection.
set lazyredraw " Don't redraw while executing macros (good performance config)
set showcmd " Show last command.
set ruler " Show the cursor position.
set matchpairs+=<:> " Pairs to match.
set cf " Enable error jumping.
set cursorline " Highlight current line
set number
set t_Co=256 " Set number of colors to 256 (Terminal)
set clipboard=unnamed " Using system clipboard
syntax on " Enable syntax highlighting.
filetype on " Detect file type.
filetype indent on " Enable file indenting.
filetype plugin indent on " Load syntax files for better indenting.
colorscheme sexy-railscasts-256 " Load colorscheme
" Airline
let g:airline#extensions#tabline#enabled = 1
" EasyGrep
let g:EasyGrepMode=0
let g:EasyGrepCommand=1
let g:EasyGrepRecursive=1
let g:EasyGrepSearchCurrentBufferDir=1
let g:EasyGrepIgnoreCase=1
let g:EasyGrepHidden=0
let g:EasyGrepFilesToExclude=''
let g:EasyGrepAllOptionsInExplorer=1
let g:EasyGrepWindow=0
let g:EasyGrepReplaceWindowMode=0
let g:EasyGrepOpenWindowOnMatch=1
let g:EasyGrepEveryMatch=0
let g:EasyGrepJumpToMatch=1
let g:EasyGrepInvertWholeWord=0
let g:EasyGrepFileAssociationsInExplorer=0
let g:EasyGrepExtraWarnings=1
let g:EasyGrepOptionPrefix='<leader>vy'
let g:EasyGrepReplaceAllPerFile=0
" Foldings
set foldmethod=syntax
set foldlevelstart=99
" Options
let mapleader = ","
let g:mapleader = ","
" Multi Cursor
let g:multi_cursor_next_key='<C-d>'
let g:multi_cursor_quit_key='<C-c>'
" AutoComplPop and autocomple
" change fold method in insert mode for autocompletion performance
autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif
autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif
" Ctags
" ,rt -> regenerate tags, including objects/functions from installed gems
map <leader>rt :!ctags --extra=+f --exclude=.git --exclude=log -R * `rvm gemdir`/gems/* `rvm gemdir`/bundler/gems/*<CR>
set tags=tags;/ " set tags-lookup-path
set iskeyword+=- " do not regard "-" as word seperator (css Files!)
" Vim Gitgutter
let g:gitgutter_realtime = 0
let g:gitgutter_eager = 0
" Mappings
map <F7> mzgg=G`z<CR> " fix indentation
map <leader>h :noh<CR> " Disable highlighting when <leader>h is pressed
map <leader>wt :call DeleteTrailingWS()<CR>
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" tabs
vmap <Tab> >gv
vmap <S-Tab> <gv
" move lines or blocks
nnoremap <S-j> :m .+1<CR>==
nnoremap <S-k> :m .-2<CR>==
inoremap <S-j> <Esc>:m .+1<CR>==gi
inoremap <S-k> <Esc>:m .-2<CR>==gi
vnoremap <S-j> :m '>+1<CR>gv=gv
vnoremap <S-k> :m '<-2<CR>gv=gv
nmap s :w<CR>
nmap q :bd<CR>
nmap td :tabc<CR>
nmap tb :TagbarToggle<CR>
nmap bl :buffers<CR>:buffer<space>
nmap ff :Grep<Space>
nmap <leader>t :Gstatus<CR>
nmap <leader>d :Gdiff<CR>
nmap <leader>g :diffget<CR>
nmap <leader>u :diffupdate<CR>
nmap <C-f> /
nmap <C-i> :tabp<CR>
nmap <C-o> :tabn<CR>
nmap <S-i> :bp<CR>
nmap <S-o> :bn<CR>
nmap <S-f> :NERDTreeFind<CR>
imap <Tab> <Space><Space>
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment