Skip to content

Instantly share code, notes, and snippets.

@ZephiroRB
Last active December 22, 2015 06:09
Show Gist options
  • Save ZephiroRB/6429304 to your computer and use it in GitHub Desktop.
Save ZephiroRB/6429304 to your computer and use it in GitHub Desktop.
Install NeoBundle
set nocompatible " Be iMproved
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#rc(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
NeoBundleFetch 'Shougo/neobundle.vim'
" Recommended to install
" After install, turn shell ~/.vim/bundle/vimproc, (n,g)make -f your_machines_makefile
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'windows' : 'make -f make_mingw32.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
" Admin Git
NeoBundle 'tpope/vim-fugitive'
" Show git repository changes in the current file
NeoBundle 'airblade/vim-gitgutter'
" Autocompletion of (, [, {, ', ", ...
NeoBundle 'delimitMate.vim'
" toggle comments
NeoBundle 'tpope/vim-commentary'
" A better looking status line
NeoBundle 'bling/vim-airline'
NeoBundle 'rstacruz/sparkup', {'rtp': 'vim/'}
NeoBundle 'tpope/vim-rails.git'
NeoBundle 'tpope/vim-bundler.git'
NeoBundle 'vim-ruby/vim-ruby.git'
NeoBundle 'scrooloose/nerdtree.git'
NeoBundle 'kchmck/vim-coffee-script.git'
NeoBundle 'tpope/vim-endwise.git'
"NeoBundle 'tpope/vim-cucumber.git'
NeoBundle 'tomtom/tcomment_vim.git'
NeoBundle 'msanders/snipmate.vim.git'
NeoBundle 'tpope/vim-haml.git'
NeoBundle 'tpope/vim-markdown.git'
NeoBundle 'git://git.wincent.com/command-t.git'
NeoBundle 'L9'
NeoBundle 'FuzzyFinder'
NeoBundle 'Lokaltog/vim-easymotion'
NeoBundle 'scrooloose/syntastic'
NeoBundle 'tpope/vim-surround'
" ...
filetype plugin indent on " Required!
"
" Brief help
" :NeoBundleList - list configured bundles
" :NeoBundleInstall(!) - install(update) bundles
" :NeoBundleClean(!) - confirm(or auto-approve) removal of unused bundles
" Installation check.
NeoBundleCheck
" Sets how many lines of history VIM has to remember
set history=700
set nu
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
let maplocalleader= ' '
" Fast saving
nmap <leader>w :w!<cr>
" Set to auto read when a file is changed from the outside
set autoread
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Turn on the WiLd menu
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win16") || has("win32")
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
else
set wildignore+=.git\*,.hg\*,.svn\*
endif
" Ignore folders rails
set wildignore+=tmp/*,public/assets/*
"Always show current position
set ruler
" Height of the command bar
set cmdheight=1
"A buffer becomes hidden when it is abandoned
set hid
"Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Search
set incsearch " incremental searching
set showmatch " show pairs match
set hlsearch " highlight search results
set smartcase " smart case ignore
set ignorecase " ignore case letters
"Don't redraw while executing macros (good performance config)
set lazyredraw
"For regular expressions turn magic on
set magic
"How many tenths of a second to blink when matching brackets
set mat=2
"No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
set foldenable
set foldmethod=marker
set foldlevel=100
set foldopen=block,hor,mark,percent,quickfix,tag
"Add a bit extra margin to the left
set foldcolumn=1
" Enable syntax highlighting
syntax enable
"Use if on terminal, not gvim
try
colorscheme Tomorrow-Night
catch
endtry
set background=dark
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions-=e
set t_Co=256
set guitablabel=%M\ %t
endif
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use Unix as the standard file type
set ffs=unix,dos,mac
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 2 spaces
set shiftwidth=2
set tabstop=2
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
set cursorline
set more
set title
set showcmd
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
set undofile
set undodir=~/.vim/undo,/tmp
" 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^=%
" Always show the status line
set laststatus=2
" Format the status line
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
autocmd BufWrite *.coffee :call DeleteTrailingWS()
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
if has("mac") || has("macunix")
nmap <D-j> <M-j>
nmap <D-k> <M-k>
vmap <D-j> <M-j>
vmap <D-k> <M-k>
endif
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <leader>t<leader> :tabnext
" Set font according to system
if has("mac") || has("macunix")
set gfn=Menlo:h15
elseif has("win16") || has("win32")
set gfn=Bitstream\ Vera\ Sans\ Mono:h11
elseif has("linux")
set gfn=Monospace\ 11
endif
" => snipMate (beside <TAB> support <CTRL-j>)
ino <c-j> <c-r>=snipMate#TriggerSnippet()<cr>
snor <c-j> <esc>i<right><c-r>=snipMate#TriggerSnippet()<cr>
" => Nerd Tree
map <leader>nn :NERDTreeToggle<cr>
map <leader>nb :NERDTreeFromBookmark
map <leader>nf :NERDTreeFind<cr>
" => Parenthesis/bracket
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
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
" airline
"set noshowmode
let g:airline_theme='powerlineish'
let g:airline_enable_branch=1
let g:airline_powerline_fonts=1
let g:airline_detect_whitespace = 1
let g:airline#extensions#hunks#non_zero_only = 1
" Commentary
nmap <Leader>c <Plug>CommentaryLine
xmap <Leader>c <Plug>Commentary
" delimitmate
let delimitMate_expand_space = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment