Skip to content

Instantly share code, notes, and snippets.

@cassianorabelo
Forked from gusaiani/.vimrc
Created June 27, 2017 02:06
Show Gist options
  • Save cassianorabelo/5c0fbc561ac40d71b08949c5175fe1c8 to your computer and use it in GitHub Desktop.
Save cassianorabelo/5c0fbc561ac40d71b08949c5175fe1c8 to your computer and use it in GitHub Desktop.
My .vimrc
call plug#begin('~/.vim/plugged')
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'jooize/vim-colemak'
Plug 'elmcast/elm-vim'
Plug 'sickill/vim-monokai'
Plug 'morhetz/gruvbox'
Plug 'elixir-lang/vim-elixir'
Plug 'pangloss/vim-javascript'
Plug 'mattn/emmet-vim'
Plug 'easymotion/vim-easymotion'
Plug 'mileszs/ack.vim'
Plug 'ggreer/the_silver_searcher'
Plug 'wavded/vim-stylus'
Plug 'tpope/vim-commentary'
Plug 'jiangmiao/auto-pairs'
Plug 'Yggdroot/indentLine'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'Shougo/neocomplete.vim'
Plug 'Valloric/YouCompleteMe'
Plug 'ervandew/supertab'
Plug 'vim-auto-save'
Plug 'wting/gitsessions.vim'
Plug 'tpope/vim-surround'
Plug 'vim-scripts/Rename2'
Plug 'vim-scripts/copypath.vim'
Plug 'terryma/vim-multiple-cursors'
Plug 'w0rp/ale'
Plug 'c-brenn/fuzzy-projectionist.vim'
Plug 'airblade/vim-gitgutter'
Plug 'vim-scripts/cmdalias.vim'
call plug#end()
au BufRead,BufNewFile *.handlebars,*.hbs set ft=html syntax=handlebars
" sync iTerm number of colors with vim at 256
let &t_Co=256
colorscheme gruvbox
" vim-auto-save: auto-save by default, except in Insert Mode
let g:auto_save = 1
let g:auto_save_in_insert_mode = 0
filetype plugin indent on
" show existing tab with 2 spaces width
set tabstop=2
" when indenting with '>', use 2 spaces width
set shiftwidth=2
" On pressing tab, insert 2 spaces
set expandtab
set number
" Highlight search results
set hlsearch
" Show incremental search
set incsearch
" Use C-style auto-indentation
set cindent
" Show quotes in json files
set conceallevel=0
map <silent> <C-\> :NERDTreeToggle<CR>
" let NERDTreeShowHidden=1
set runtimepath+=~/.vim/my-snippets/
:au FocusLost * :wa
:set autowriteall
autocmd BufWritePre * %s/\s\+$//e
" Treat zero-padded numbers as decimal rather than octal
set nrformats=
" Tab character colors
let g:indentLine_color_term = 236
let g:indentLine_char = '|'
" CtrlP fuzzy navigator
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn|tmp|node_modules)$',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'some_bad_symbolic_links',
\ }
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
set wildignore+=.DS_Store
" Ignore patterns for netrw
let g:netrw_list_hide='.*\.git,.*\.DS_Store$'
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" autoformat Elm using elm-vim plugin
let g:elm_format_autosave = 1
" backspace over line breaks in Insert mode
set backspace=indent,eol,start
" Customize tabs for filetypes
autocmd Filetype elm setlocal ts=4 sts=4 sw=4
" Make it easier to go to next line from middle of
" current one in Insert mode
imap <C-o> <esc>o
imap <C-S-o> <esc><S-o>
" Fixes issue where cursor moves after a save
let g:syntastic_auto_jump = 0
" Copy yanks to system clipboard
set clipboard=unnamed,unnamedplus
" Emmet
let g:user_emmet_mode='a' "enable all function in all mode.
let g:user_emmet_leader_key='<C-Z>'
let g:user_emmet_install_global = 0
autocmd FileType html,css,hbs EmmetInstall
" open Visual-Block mode with ctrl+v
nnoremap <c-a> <c-v>
" ZSH-style tab completion in Ex mode
set wildmenu
set wildmode=full
" Have up to 200 commands saved
set history=200
" Open vertical splits on the right
set splitright
" Open horizontal splits below
set splitbelow
let mapleader = " "
" Shortcuts for buffer navigation
nnoremap <silent> [b :bprevious<CR>
nnoremap <silent> ]b :bnext<CR>
nnoremap <silent> [B :bfirst<CR>
nnoremap <silent> ]B :blast<CR>
" Disable error sounds
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
" Copy everything to clipboard
set clipboard=unnamed
" Editor basics {{{
" Behave like Vim instead of Vi
set nocompatible
" Show a status line
set laststatus=2
" Show the current cursor position
set ruler
" Enable syntax highlighting
syn on
" }}}
" Mouse {{{
" Send more characters for redraws
set ttyfast
" Enable mouse use in all modes
set mouse=a
" Set this to the name of your terminal that supports mouse codes.
" Must be one of: xterm, xterm2, netterm, dec, jsbterm, pterm
set ttymouse=xterm2
" Expand to the path of the active buffer with :%%
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
" Enable matchit plugin (% for jumping between open/close xml tags)
filetype plugin on
runtime macros/matchit.vim
" Set * and #, in Visual mode,
" to jump around selected substrings
xnoremap * :<C-u>call <SID>VSetSearch('/')<CR>/<C-R>=@/<CR><CR>
xnoremap # :<C-u>call <SID>VSetSearch('?')<CR>?<C-R>=@/<CR><CR>
function! s:VSetSearch(cmdtype)
let temp = @s
norm! gv"sy
let @/ = '\V' . substitute(escape(@s, a:cmdtype.'\'), '\n', '\\n', 'g') let @s = temp
endfunction
" Use ag under the hood for Ack
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" Esc to close quickfix window (Ack results)
" nnoremap <silent> <ESC> :ccl<CR>
" Don't jump to first result in Ack
" cnoreabbrev Ack Ack!
" nnoremap <Leader>a :Ack!<Space>
" Fuzzy Finder
set rtp+=/usr/local/opt/fzf
" Navigate splits quicker
nnoremap <C-J> <C-W><C-J>
nnoremap <C-E> <C-W><C-K>
nnoremap <C-I> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Go to tab
noremap <leader>u gt
noremap <leader>l gT
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
noremap <leader>0 :tablast<cr>
" Go to last active tab
au TabLeave * let g:lasttab = tabpagenr()
nnoremap <silent> <c-l> :exe "tabn ".g:lasttab<cr>
vnoremap <silent> <c-l> :exe "tabn ".g:lasttab<cr>
" Toggle Comment
noremap <leader>c gcc
" Quick new tabedit (empty)
noremap <leader>t :tabedit<cr>
" Quick new tabclose (empty)
noremap <leader><leader>c :tabclose<cr>
" Quick :only
noremap <leader>o :only<cr>
" Comment
noremap <leader>c :Commentary<cr>
" Remap ; to : to access commands more easily
nnoremap ; :
vnoremap ; :
" Use :a to trigger :Ack
autocmd VimEnter * Alias a Ack
" Reload vim-colemak to remap any overridden keys
silent! source "$HOME/.vim/plugged/vim-colemak/plugin/colemak.vim"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment