Created
June 12, 2016 22:13
-
-
Save felipap/5741c60c5ef1e22964a1cde29859595b to your computer and use it in GitHub Desktop.
.vimrc as of today
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" I can't believe I'm redoing this. | |
" List of sources this .vimrc was based on: | |
" - https://amix.dk/vim/vimrc.html | |
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'VundleVim/Vundle.vim' | |
Plugin 'chriskempson/base16-vim' | |
Plugin 'altercation/vim-colors-solarized' | |
Plugin 'wookiehangover/jshint.vim' | |
Plugin 'scrooloose/syntastic' | |
Plugin 'fatih/vim-go' | |
Plugin 'terryma/vim-multiple-cursors' | |
Plugin 'nsf/gocode', {'rtp': 'vim/'} | |
Plugin 'scrooloose/nerdcommenter' | |
Bundle 'jistr/vim-nerdtree-tabs' | |
" Plugin 'scrooloose/nerdTree' | |
Plugin 'bling/vim-airline' | |
Plugin 'flazz/vim-colorschemes' | |
Plugin 'maksimr/vim-jsbeautify' | |
Plugin 'tpope/vim-surround' | |
Plugin 'Valloric/YouCompleteMe' | |
Plugin 'easymotion/vim-easymotion' | |
Plugin 'pangloss/vim-javascript' | |
Bundle 'mxw/vim-jsx' | |
call vundle#end() | |
" set laststatus=2 | |
""""""""" | |
" General | |
""""""""" | |
set history=700 " set # lines vim has to remember | |
filetype plugin on " enable filetype plugins | |
filetype indent on | |
set autoread " autoread when file is changed | |
let mapleaader = "," " 'O | |
let g:mapleader = "," | |
nmap <leader>w :w!<cr> " fast saving | |
noremap! <C-BS> <C-w> | |
noremap! <C-h> <C-w> | |
set mouse=a | |
set ttyfast | |
""""""""""" | |
" Interface | |
""""""""""" | |
set so=3 " set 3 lines to cursor when moving vertically | |
set wildmenu " turn on wiLd menu | |
set wildignore=*.o,*~,*.pyc " ignore compiled files | |
set ruler " always show current position | |
set cmdheight=2 " height of the command bar | |
set hid " a buffer becomes hidden when abandoned | |
set backspace=eol,start,indent " backspace acts the way it should | |
set whichwrap+=<,>h,l | |
"set ignorecase " ignore case when searching | |
set smartcase " try to be smart about cases while searching | |
set hlsearch " highlight search results | |
set incsearch " make search act like search in modern browsers | |
set magic " for regular expressions, turn magic on | |
set number | |
set relativenumber | |
set showcmd | |
set cursorline " highlight current line | |
set lazyredraw | |
" show matching brackets when text indicator is over | |
set showmatch | |
" 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 | |
" folding | |
set foldenable | |
set foldlevelstart=10 | |
set foldnestmax=10 | |
nnoremap <space> za " space opens/closes folders | |
set foldmethod=indent | |
" Better copy & paste | |
set pastetoggle=<F2> | |
set pastetoggle=<leader>p | |
set clipboard=unnamed | |
"""""""""""""""" | |
" colors & fonts | |
"""""""""""""""" | |
syntax enable " enable syntax highlighting | |
set background=dark | |
if has("gui_running") | |
set guioptions-=T | |
set guioptions+=e | |
set t_Co=256 | |
set guitablabel=%M\ %t | |
endif | |
set encoding=utf8 " set utf8 as std encoding | |
""""""""""""""""""""""""" | |
" files & backups & undos | |
""""""""""""""""""""""""" | |
" Turn backgrup off, since most stuff is in SVN anayway... | |
set nobackup | |
set nowb | |
set noswapfile | |
"""""""""""""""""""""""""""""" | |
" text, tabs and ident related | |
"""""""""""""""""""""""""""""" | |
set smarttab " be smart when using tabs :) | |
set shiftwidth=2 " 1 tab == 4 spaces | |
set tabstop=2 | |
set expandtab " tabs are spaces | |
set softtabstop=2 " | |
" Linebreak on 500 characters | |
set lbr | |
set tw=500 | |
set ai " Auto indent | |
set si " Smart indent | |
set wrap " Wrap lines | |
"""""""""""""""""""""""""""""" | |
" => Visual mode related | |
"""""""""""""""""""""""""""""" | |
" Visual mode pressing * or # searches for the current selection | |
" Super useful! From an idea by Michael Naumann | |
vnoremap <silent> * :call VisualSelection('f')<CR> | |
vnoremap <silent> # :call VisualSelection('b')<CR> | |
""""""""""""""" | |
" moving around | |
""""""""""""""" | |
" Treat long lines as break lines | |
map j gj | |
map k gk | |
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search) | |
" map <space> / | |
map <c-space> ? | |
" Disable highlight when <leader><cr> is pressed | |
map <silent> <leader><space> :noh<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 | |
" Highlight line surpassing 80 characters | |
match ErrorMsg '\%>80v.\+' " | |
" easier moving between tabs | |
map <Leader>n <esc>:tabprevious<CR> | |
map <Leader>m <esc>:tabnext<CR> | |
" Close the current buffer | |
map <leader>bd :Bclose<cr> | |
" Close all the buffers | |
map <leader>ba :1,1000 bd!<cr> | |
" Useful mappings for managing tabs | |
map <leader>tn :tabnew<cr> | |
map <leader>to :tabonly<cr> | |
map <leader>tc :tabclose<cr> | |
map <leader>tm :tabmove | |
" Opens a new tab with the current buffer's path | |
" Super useful when editing files in the same directory | |
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/ | |
" Switch CWD to the directory of the open buffer | |
map <leader>cd :cd %:p:h<cr>:pwd<cr> | |
" Specify the behavior when switching between buffers | |
try | |
set switchbuf=useopen,usetab,newtab | |
set stal=2 | |
catch | |
endtry | |
" 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^=% | |
" save on cmd-s? | |
" map <M-s> :w<kEnter> "Works in normal mode, must press Esc first" | |
" imap <M-s> <Esc>:w<kEnter>i "Works in insert mode, saves and puts back in insert mode" | |
" http://stackoverflow.com/questions/7885198 | |
if has('mac') && ($TERM == 'xterm-256color' || $TERM == 'screen-256color') | |
map <Esc>OP <F1> | |
map <Esc>OQ <F2> | |
map <Esc>OR <F3> | |
map <Esc>OS <F4> | |
map <Esc>[16~ <F5> | |
map <Esc>[17~ <F6> | |
map <Esc>[18~ <F7> | |
map <Esc>[19~ <F8> | |
map <Esc>[20~ <F9> | |
map <Esc>[21~ <F10> | |
map <Esc>[23~ <F11> | |
map <Esc>[24~ <F12> | |
endif | |
"""""""""""""""""" | |
" editing mappings | |
"""""""""""""""""" | |
" 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 | |
" 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() | |
""""""""""""""""""" | |
" => Spell checking | |
""""""""""""""""""" | |
" Pressing ,ss will toggle and untoggle spell checking | |
map <leader>ss :setlocal spell!<cr> | |
" Shortcuts using <leader> | |
map <leader>sn ]s | |
map <leader>sp [s | |
map <leader>sa zg | |
map <leader>s? z= | |
" Toggle paste mode on and off | |
map <F3> :setlocal paste!<cr> | |
colorscheme base16-default | |
colorscheme desert | |
colorscheme molokai | |
colorscheme badwolf | |
set noswapfile | |
""""""""""" | |
"" configs for plugins | |
let g:go_fmt_command = "goimports" | |
hi TabLineFill ctermfg=Black |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment