Skip to content

Instantly share code, notes, and snippets.

@abullrd
Last active August 29, 2015 14:24
Show Gist options
  • Save abullrd/513ab7befb87ba476874 to your computer and use it in GitHub Desktop.
Save abullrd/513ab7befb87ba476874 to your computer and use it in GitHub Desktop.
.vimrc
execute pathogen#infect()
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => nerdTree
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <C-n> :NERDTreeToggle<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => CtrP
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <C-t> :CtrlP<CR>
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" search the nearest ancestor that contains one of these directories or files: .git .hg .svn .bzr
let g:ctrlp_working_path_mode = 'r'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Powerline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set rtp+=/usr/local/lib/python2.7/site-packages/powerline/bindings/vim
" Always show status bar
set laststatus=2
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => fugitive.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>gb :Gblame<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Gundo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <F5> :GundoToggle<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => ag.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap ,f :Ag
" start searching from your project root instead of the cwd
let g:ag_working_path_mode="r"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Syntastic
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:syntastic_javascript_checkers = ['jshint', 'eslint']
" Dont auto check on open or save (for speed)
let g:syntastic_mode_map = { "mode": "passive" }
nnoremap <leader>h :SyntasticCheck<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => vim-commentary - use it w/ gc<motion>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" Enable filetype plugins
filetype plugin indent on
" set undo to global dir
if isdirectory($HOME . '/.vim/_undo') == 0
:silent !mkdir -p ~/.vim/_undo > /dev/null 2>&1
endif
set undodir=~/.vim/_undo//
set undofile
set backupdir=~/.vim/_backup//
set directory=~/.vim/_temp//
" Set to auto read when a file is changed from the outside
set autoread
" hides buffers instead of closing them
set hidden
map <leader>s :call OpenRival()<cr>
map <leader>ss :call OpenScreenshot()<cr>
let g:omni_sql_no_default_maps = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim command autocomplete
set wildmenu
set wildmode=longest:full,full
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" defaults search to use /g
set gdefault
" Don't redraw while executing macros (good performance config)
set lazyredraw
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
colorscheme gardener
set guifont=Anonymous_Pro_for_Powerline:h14
au BufNewFile,BufRead *._js set filetype=javascript
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set spell
" visible whitespace
set list
" Make whitespace less crazy
if &listchars ==# 'eol:$'
set listchars=tab:>\ ,trail:\ ,extends:>,precedes:<,nbsp:+
endif
" Change SpecialKey highlighting to emphasize trailing whitespace
hi SpecialKey guibg=#851111
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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 relativenumber
set wrap
set textwidth=79
set formatoptions=qrn1
set colorcolumn=85
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Cursor
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set cursorline
set cursorcolumn
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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^=%
nnoremap <tab> %
vnoremap <tab> %
nnoremap j gj
nnoremap k gk
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper Functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! ToggleColorScheme()
let c = 'github'
redir => scheme
silent colorscheme
redir END
echo scheme
if scheme == "github"
let c = 'elflord'
endif
execute 'colorscheme ' . c
endfunction
function! OpenRival()
cd ~/Programming/node/rivaliq-server
execute 'NERDTreeToggle'
endfunction
function! OpenScreenshot()
cd ~/Programming/node/rivaliq-screenshot
execute 'NERDTreeToggle'
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Reload vimrc on change
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment