Skip to content

Instantly share code, notes, and snippets.

@amsheehan
Created December 2, 2016 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amsheehan/69b0758a346d989045789dac0fbecae2 to your computer and use it in GitHub Desktop.
Save amsheehan/69b0758a346d989045789dac0fbecae2 to your computer and use it in GitHub Desktop.
execute pathogen#infect()
"""""""""""""""
" Navigation "
"""""""""""""""
set bs=indent,eol,start
set incsearch
set hlsearch
nnoremap t :tabedit<CR>
nnoremap <c-h> :tabp<CR>
nnoremap <c-l> :tabn<CR>
"map Alt+j, Alt+k to move up/down 10 lines nnoremap ∆ 10j
nnoremap ∆ 5j
nnoremap ˚ 5k
vnoremap ∆ 5j
vnoremap ˚ 5k
"map Shift+Alt+j, Shift+Alt+k to move up/down 20 lines
nnoremap Ô 15j
nnoremap  15k
vnoremap Ô 15j
vnoremap  15k
""""""""""""""
" Appearance "
""""""""""""""
syntax on
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set number
set autoindent
set smartindent
" Autocomplete Colors
highlight Pmenu ctermfg=255 ctermbg=125
highlight PmenuSel ctermfg=255 ctermbg=240
""""""""""""""""
" Key Mappings "
""""""""""""""""
map <F2> :NERDTreeFocus<CR>
map <F3> :NERDTreeToggle<CR>
map <F4> :CtrlP<CR>
"""""""""""""""""""""""
" Leader Key Mappings "
"""""""""""""""""""""""
let mapleader=","
nnoremap <leader>u :GundoToggle<CR>
nnoremap <leader><space> :noh<CR>
" System clipboard
noremap <Leader>c "*y
noremap <Leader>v "*p
noremap <Leader>c "+y
noremap <Leader>v "+p
nnoremap <leader>j :%!python -m json.tool<CR>
""""""""""""""""""""""""""""""""""
" Silver Searcher instead of Ack "
""""""""""""""""""""""""""""""""""
let g:ackprg = 'ag --vimgrep --smart-case'
cnoreabbrev ag Ack
cnoreabbrev aG Ack
cnoreabbrev Ag Ack
cnoreabbrev AG Ack
"""""""""""
" Folding "
"""""""""""
"define custom folding function (taken from: http://vim.wikia.com/wiki/Customize_text_for_closed_folds)
function! CustomFold()
let line = getline(v:foldstart)
if match( line, '^[ \t]*\(\/\*\|\/\/\)[*/\\]*[ \t]*$' ) == 0
let initial = substitute( line, '^\([ \t]\)*\(\/\*\|\/\/\)\(.*\)', '\1\2', '' )
let linenum = v:foldstart + 1
while linenum < v:foldend
let line = getline( linenum )
let comment_content = substitute( line, '^\([ \t\/\*]*\)\(.*\)$', '\2', 'g' )
if comment_content != ''
break
endif
let linenum = linenum + 1
endwhile
let sub = initial . ' ' . comment_content
else
let sub = line
let startbrace = substitute( line, '^.*{[ \t]*$', '{', 'g')
if startbrace == '{'
let line = getline(v:foldend)
let endbrace = substitute( line, '^[ \t]*}\(.*\)$', '}', 'g')
if endbrace == '}'
let sub = sub.substitute( line, '^[ \t]*}\(.*\)$', '...}\1', 'g')
endif
endif
endif
let n = v:foldend - v:foldstart + 1
let info = " " . n . " lines"
let sub = sub . " >>>"
let num_w = getwinvar( 0, '&number' ) * getwinvar( 0, '&numberwidth' )
let fold_w = getwinvar( 0, '&foldcolumn' )
let sub = strpart( sub, 0, winwidth(0) - strlen( info ) - num_w - fold_w - 1 )
return sub . info
endfunction
"set fold method to custom function
set foldtext=CustomFold()
"press space to toggle folding; if no fold, default behavior
nnoremap <silent>\\ @=(foldlevel('.')?'za':"\<Space>")<CR>
vnoremap \\ zf
" placed at bottom so nothing interpreted after
inoremap jk <esc>
inoremap kj <esc>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment