Skip to content

Instantly share code, notes, and snippets.

@darrnshn
Last active January 23, 2017 23:40
Show Gist options
  • Save darrnshn/63c8ce12985e762e4b61ccc4350edb41 to your computer and use it in GitHub Desktop.
Save darrnshn/63c8ce12985e762e4b61ccc4350edb41 to your computer and use it in GitHub Desktop.
vimrc
" plugins
call plug#begin('~/.vim/bundle')
Plug 'altercation/vim-colors-solarized'
Plug 'ctrlpvim/ctrlp.vim' " navigate folders
Plug 'justinmk/vim-sneak' " jump around
Plug 'ervandew/supertab' " auto complete
Plug 'tpope/vim-commentary'
Plug 'darrnshn/vim-sleuth'
Plug 'wellle/targets.vim'
Plug 'tpope/vim-surround'
call plug#end()
" colours
syntax enable
set background=light
colorscheme solarized
" use space for leader key
map <Space> <Leader>
" leader shortcuts
nnoremap <Leader>w :w!<CR>
nnoremap <Leader>p "+p
vnoremap <Leader>y "+y
vnoremap <Leader>d "+d
nnoremap <Leader>a ^
nnoremap <leader>e $
" jump to middle of line
nnoremap gm :call cursor(0, virtcol('$')/2)<CR>
" jump to end of text when copying and pasting
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
" relative line numbers for better jumping
set relativenumber
" make backspace behave
set backspace=2
" quick escape
inoremap jk <c-c>`^
" vimsneak plugin
let g:sneak#use_ic_scs = 1 " case insensitive
let g:sneak#streak = 1
" scratch pad plugin
nnoremap <Leader>S :Scratch<CR>
set showmode " show visual/normal/insert mode
set cursorline " highlight current line
set ignorecase " ignore case in searches
set incsearch " incremental search
set hlsearch " highlight searches
set ruler " show cursor position
set lazyredraw " possible optimization?
set hidden " don't close buffers
set wildmenu " autocomplete filenames
set wildignore=*.swp,*.bak,*.pyc,*.class " ignore certain files
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
" search through buffers
:nnoremap <c-s-p> :CtrlPBuffer<CR>
" move vertically by visual line if we're not jumping
nnoremap <expr> j v:count ? 'j' : 'gj'
nnoremap <expr> k v:count ? 'k' : 'gk'
" type {{ to open new code block
inoremap {{ {<CR>}<Esc>O
" clear search using //
nmap <silent> // :nohlsearch<CR>
" highlight trailing space
set list
set listchars=trail:·
" don't really want to accidentally open man page
map <S-k> <Nop>
" buffer movement
map <Tab> :bnext<CR>
map <S-Tab> :bprevious<CR>
" split movement
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" more natural split
set splitbelow
set splitright
" highlight matching bracket with different colour
highlight MatchParen cterm=none ctermbg=red
" triple slash Doxygen comments
autocmd Filetype c,cpp set comments^=:///
" select text pasted
noremap gV `[v`]
" prevent accidental deletions
inoremap <C-U> <Nop>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment