Skip to content

Instantly share code, notes, and snippets.

@Robert-Wett
Last active December 10, 2015 21:21
Show Gist options
  • Save Robert-Wett/5d97a02f0bef5540478d to your computer and use it in GitHub Desktop.
Save Robert-Wett/5d97a02f0bef5540478d to your computer and use it in GitHub Desktop.
.vimrc
execute pathogen#infect()
set nu
set numberwidth=2
set incsearch
set ignorecase
set tabstop=2
set shiftwidth=2
set expandtab
" Based on the current language set, any time you insert, it'll auto format
" for you
set smartindent
set nowrap
" Supposed to enable copying
set clipboard=unnamed
syntax on
inoremap jk <Esc>
" Control + k/j moves down 5 lines a peice. Really useful for navigating
" larger files and keeping the context of where the cursor was before pressing
" it
map <C-k> 5k
map <C-j> 5j
" NERDTree Stuff
" Control + D will toggle the NERDTree sidebar. The % sign will force it
" to focus on the current file and directory
map <C-d> :NERDTreeToggle %<CR>
" http://vim.wikia.com/wiki/Backspace_and_delete_problems
set backspace=indent,eol,start
" Hightlight search finds
set hlsearch
" Sets the center of the screen to the found item in search
set scrolloff=5
set sidescroll=1
set sidescrolloff=10
" http://vim.wikia.com/wiki/Great_wildmode/wildmenu_and_console_mouse
set wildmode=list:longest,full
set spelllang=en_us
" remove highlight after escaping search, hitting escape then u (un-highlight)
map <ESC>u :nohlsearch<CR>
" Stop the adding of a space on a join
set nojoinspaces
" Stop beeping!
set vb t_vb=
" Move by visible lines, not physical lines. This is super dope sometimes if
" you have to have wrapping on, and you have someone writing code or functions
" that are fucking 500 characters long and you press 'j' to move up a line and
" it moves up like fucking 6 lines
map j gj
map k gk
" Add a date with f5. This is with a plugin.. I think
:nnoremap <F5> "=strftime("%c")<CR>P
:inoremap <F5> <C-R>=strftime("%c")<CR>
" Test stuff, folding
set foldminlines=2
set foldlevelstart=1
set foldnestmax=2
set foldmethod=indent
filetype plugin indent on
nmap <Tab> :set expandtab!<CR>:set expandtab?<CR>
" autocmd FileType javascript,less,html set foldnestmax=3 formatoptions-=o
" 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
" Enable mouse
set mouse=a
" Enable Solarized Theme
" syntax enable
" set background=dark
" colorscheme solarized
" colors Guardian
"
" Recursively find files with :find myFile.js
" Recursively find files with :tabf myFile.js
set path=.,**,,
" http://www.agillo.net/simple-vim-window-management/
let mapleader=" "
function! WinMove(key)
let t:curwin = winnr()
exec "wincmd ".a:key
if (t:curwin == winnr()) "we havent moved
if (match(a:key,'[jk]')) "were we going up/down
wincmd v
else
wincmd s
endif
exec "wincmd ".a:key
endif
endfunction
" Leader + hjkl will copy/move the window. leader is set to space
map <leader>h :call WinMove('h')<cr>
map <leader>k :call WinMove('k')<cr>
map <leader>l :call WinMove('l')<cr>
map <leader>j :call WinMove('j')<cr>
" I also use <leader>wc to close a window. The mnemonic is 'window close' and
" <leader>wr to rotate windows or 'window rotate'
map <leader>wc :wincmd q<cr>
map <leader>wr <C-W>r
" vim also allows you to move existing windows. I use this more than
" Rotate, it follows the same principle as before using hjkl, but relies
" on it's capital forms:
map <leader>H :wincmd H<cr>
map <leader>K :wincmd K<cr>
map <leader>L :wincmd L<cr>
map <leader>J :wincmd J<cr>
" Resize windows with arrow keys
nmap <left> :3wincmd <<cr>
nmap <right> :3wincmd ><cr>
nmap <up> :3wincmd +<cr>
nmap <down> :3wincmd -<cr>
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
let g:syntastic_check_on_w = 0
let g:syntastic_aggregate_errors=1
let g:syntastic_error_symbol=''
let g:syntastic_warning_symbol=''
let g:syntastic_enable_ballons=has('ballon_eval')
let g:syntastic_auto_jump=1
let g:syntastic_loc_list_height=3
let g:syntastic_ignore_files = ['^/usr/', '*node_modules*', '*vendor*', '*build*', '*LOCAL*', '*BASE', '*REMOTE*']
" Make the git-gutter refresh after you stop typing
let g:gitgutter_realtime = 1
" This will need to be commented out if you don't have pathogen installed.
" Pathogen is a plugin manager that's really popular
execute pathogen#infect()
" Add line numbers
set nu
" I'm a javascript guy, so I like 2 spaces for everything
set numberwidth=2
" Incrementally search WHILE typing, as opposed to waiting for the enter key
set incsearch
" Non case-sensitive search
set ignorecase
" If people use tabs, set them to 2 spaces
set tabstop=2
" Number of space characters inserted for indentation,
set shiftwidth=2
" This converts tabs to spaces. DONT MIX TABS AND SPACES BABY
set expandtab
" Based on the current language set, any time you insert, it'll auto format
" for you
set smartindent
" Turn off word wrapping
set nowrap
" Turn on syntax highlighting
syntax on
" This one is personal preference, but I love this shit. When you are
" in INSERT MODE, pressing 'jk' will escape it. A lot of people will
" bind this to caps lock or 'jj'
inoremap jk <Esc>
" Control + k/j moves down 5 lines a peice. Really useful for navigating
" larger files and keeping the context of where the cursor was before pressing
" it
map <C-k> 5k
map <C-j> 5j
" NERDTree Stuff
" Control + d will toggle the NERDTree sidebar. The % sign will force it
" to focus on the current file and directory
map <C-d> :NERDTreeToggle %<CR>
" http://vim.wikia.com/wiki/Backspace_and_delete_problems
set backspace=indent,eol,start
" Hightlight search finds
set hlsearch
" Sets the center of the screen to the found item in search
set scrolloff=5
set sidescroll=1
set sidescrolloff=10
" http://vim.wikia.com/wiki/Great_wildmode/wildmenu_and_console_mouse
set wildmode=list:longest,full
set spelllang=en_us
" remove highlight after escaping search, hitting escape then u (un-highlight)
map <ESC>u :nohlsearch<CR>
" Stop the adding of a space on a join
set nojoinspaces
" Stop beeping!
set vb t_vb=
" Move by visible lines, not physical lines. This is super dope sometimes if
" you have to have wrapping on, and you have someone writing code or functions
" that are fucking 500 characters long and you press 'j' to move up a line and
" it moves up like fucking 6 lines
map j gj
map k gk
" Add a date with f5. This is with a plugin.. I think
:nnoremap <F5> "=strftime("%c")<CR>P
:inoremap <F5> <C-R>=strftime("%c")<CR>
" Test stuff, folding
set foldminlines=2
set foldlevelstart=1
set foldnestmax=2
filetype plugin indent on
nmap <Tab> :set expandtab!<CR>:set expandtab?<CR>
" autocmd FileType javascript,less,html set foldnestmax=3 formatoptions-=o
" 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
" Enable mouse
set mouse=a
" Enable Solarized Theme
" syntax enable
" set background=dark
" colorscheme solarized
" colors Guardian
"
" Recursively find files with :find myFile.js
" Recursively find files with :tabf myFile.js
set path=.,**,,
" http://www.agillo.net/simple-vim-window-management/
let mapleader=" "
function! WinMove(key)
let t:curwin = winnr()
exec "wincmd ".a:key
if (t:curwin == winnr()) "we havent moved
if (match(a:key,'[jk]')) "were we going up/down
wincmd v
else
wincmd s
endif
exec "wincmd ".a:key
endif
endfunction
" Leader + hjkl will copy/move the window. leader is set to space
" I don't really like this piece
map <leader>h :call WinMove('h')<cr>
map <leader>k :call WinMove('k')<cr>
map <leader>l :call WinMove('l')<cr>
map <leader>j :call WinMove('j')<cr>
" I also use <leader>wc to close a window. The mnemonic is 'window close' and
" <leader>wr to rotate windows or 'window rotate'
" I use the close command the mose (with our leader to space, it's space+w+c)
map <leader>wc :wincmd q<cr>
map <leader>wr <C-W>r
" vim also allows you to move existing windows. I use this more than
" Rotate, it follows the same principle as before using hjkl, but relies
" on it's capital forms:
" (This is more useful)
map <leader>H :wincmd H<cr>
map <leader>K :wincmd K<cr>
map <leader>L :wincmd L<cr>
map <leader>J :wincmd J<cr>
" Resize windows with arrow keys
nmap <left> :3wincmd <<cr>
nmap <right> :3wincmd ><cr>
nmap <up> :3wincmd +<cr>
nmap <down> :3wincmd -<cr>
" Syntastic Stuff - https://github.com/scrooloose/syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" Defines how/when we populate teh bottom window of errors
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
" Don't automatically run the file through the checker on open
let g:syntastic_check_on_open = 0
" Or on save
let g:syntastic_check_on_wq = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment