Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

928 lines (744 sloc) 39.804 kb
"***************************************************************************************************
" Key-mappings list
"
" NOTE:
" * <C-O> escapes I-Mode to execute command and then returns back to I-Mode.
" Also, if cursor is placed beyond the last character in insert mode, when returning to insert mode, it is moved left.
" To prevent this, use <C-\><C-O>
" Identify directory that vimrc resides in (For compatibility with both *nix and windows)
redir => s:scriptnames|silent scriptnames|redir END
let g:vim_dir = fnamemodify(split(filter(split(s:scriptnames,'\n'), 'v:val =~ "[\\/]vimrc"')[0],'\s\+')[1], ':h')
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Leader commands {{{1
"""""""""""""""""""
" Default leader is '\'
let mapleader = ","
""" S
nnoremap <silent> <leader>sv :so $MYVIMRC<CR>:so $MYGVIMRC<CR>
nnoremap <silent> <leader>sb :call myFunctions#ScrollBind()<CR>
nnoremap <leader>sr :reg<CR>
nnoremap <leader>sm :marks<CR>
" nnoremap <leader>sy : Yankring
" Set size
nnoremap <silent> <expr> <leader>ss0 ':set lines=' . ( tabpagenr("$") == 1 ? '62' : '61' ) . ' columns=' . ( winnr('$') == 1 ? '316' : '314' ) . '<CR>'
nnoremap <silent> <expr> <leader>ss2 ':set lines=' . ( tabpagenr("$") == 1 ? '70' : '68' ) . ' columns=' . ( winnr('$') == 1 ? '274' : '272' ) . '<CR>'
""" P - Perforce
nnoremap <silent> <leader>pe :call system("p4 edit " . b:p4path . " > /dev/null")<CR>
nnoremap <silent> <leader>pr :call system("p4 revert " . b:p4path . " > /dev/null")<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" GOTO commands {{{1
"""""""""""""""""
execute 'nnoremap <silent> govv :e ' . g:vim_dir . '/vimrc<CR>'
execute 'nnoremap <silent> govg :e ' . g:vim_dir . '/gvimrc<CR>'
execute 'nnoremap <silent> govf :e ' . g:vim_dir . '/autoload/myFunctions.vim<CR>'
execute 'nnoremap <silent> govm :e ' . g:vim_dir . '/mappings.vim<CR>'
execute 'nnoremap <silent> govb :e ' . g:vim_dir . '/bundle.vim<CR>'
nnoremap <silent> gorp :e ~/Dropbox/Softwares/Readmes/personal/README.toc.txt<CR>
nnoremap <silent> gora :e ~/Dropbox/Softwares/Readmes/amd/AMD.toc.txt<CR>
nnoremap <silent> gosr :e ~/.bashrc<CR>
nnoremap <silent> gosa :e ~/Dropbox/Softwares/Linux/aliases<CR>
nnoremap <silent> gosw :e ~/Dropbox/Softwares/Linux/aliases_work<CR>
nnoremap <silent> gosf :e ~/Dropbox/Softwares/Linux/bash/bash_func<CR>
nnoremap <silent> gosp :e ~/Dropbox/Softwares/Linux/bash/bash_prompt<CR>
""" Redirect F1 to list of all commands which is more useful than the default help page
noremap <F1> :vert bo h index<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Re-mapping for convenience {{{1
""""""""""""""""""""""""""""""
""" Netrw
nnoremap - :Ex<CR>
autocmd FileType netrw nnoremap qq :Rex<CR>
""" Remap w to behave as 'w' should in all cases (:h cw). Use ce to do what 'cw' used to
onoremap w :<C-U>norm w<CR>
onoremap W :<C-U>norm W<CR>
""" Save read-only files with sudo
command! W w !sudo tee % > /dev/null
""" Override vim commands 'gf', '^Wf', '^W^F'
":nnoremap gf :view <cfile><cr>
"nnoremap gf :call GotoFile("")<CR>
"nnoremap <C-W>f :call GotoFile("new")<CR>
" wincmd is the same as <C-W>
"nnoremap <C-W>f :vertical wincmd f<CR>
""" Making line-completion consistent with word-completion for Ctrl+N
inoremap <C-X><C-L> <C-X><C-L><C-N><C-N>
""" Repeating motion when tTfF is used (Default behavior overriden by vim-sneak)
" \ goes to next occurrence and | to previous occurrence
"nnoremap \ ;
"nnoremap \| ,
""" Replace : with ;
" ; is used originally for moving to next instance in same direction after tTfF, remapped to \ above
nnoremap ; :
vnoremap ; :
""" Show full file path while opening file
cabbrev %% <C-R>=fnameescape( expand( '%:p' ))<CR>
nnoremap ,s% :source <C-R>=fnameescape( expand( '%:p' ))<CR><CR>
cabbrev <expr> E (( getcmdtype() == ':' && getcmdpos() <= 2 ) ? 'e <C-R>=fnameescape( expand( "%:p:h" ))."/"<CR><C-R>=myFunctions#EatChar("\\s")<CR>' : 'E' )
""" Jumps
" Move around the changelist
nnoremap <silent> g; :exec "normal! g;zvzz" . float2nr(winheight(0)*0.2) . "\<Lt>C-E>"<CR>
nnoremap <silent> g, :exec "normal! g,zvzz" . float2nr(winheight(0)*0.2) . "\<Lt>C-E>"<CR>
" Move around the jumplist
nnoremap <silent> <C-O> :exec "normal! \<Lt>C-O>zvzz" . float2nr(winheight(0)*0.1) . "\<Lt>C-E>"<CR>
" FIXME:
"nnoremap <silent> <C-I> :exec "normal! \<Lt>C-I>zvzz" . float2nr(winheight(0)*0.1) . "\<Lt>C-E>"<CR>
""" Display full path and filename
nnoremap <C-G> 2<C-G>
" Copy the file name to unix visual select buffer
nnoremap <C-A-g>p :let @* = expand('%:p')<CR>
""" Open help in a vertically split window. Use `:set splitright` to open on the right
cabbrev <expr> h (( getcmdtype() == ':' && getcmdpos() <= 2 ) ? 'vert bo h' : 'h' )
""" First and last non-blank character on the line
" omap doesn't work due to Yankring mappings
"nnoremap H ^
"onoremap H ^
"nnoremap L g_
"onoremap L g_
""" Use aesthetic middle of screen for 'zz' (Offsets it a little to the top)
if has('float')
nnoremap <silent> zz :exec "normal! zz" . float2nr(winheight(0)*0.1) . "\<Lt>C-E>"<CR>
endif
""" Persistent paste in visual mode
" By default, p/P in visual mode pastes the contents of the default register and replaces it with the visual selection.
" This will preserve the original contents. For the default behavior, P can be used
"xnoremap p "_dP
"xnoremap <expr> p v:register=='"':'pgvy':'p'
""" Paste and indent ( Causes more pain than help )
"let g:yankring_paste_n_akey = ''
"let g:yankring_paste_n_bkey = ''
"nnoremap p :<C-U>YRPaste 'p'<CR>=`]
"nnoremap P :<C-U>YRPaste 'P'<CR>=`]
""" Jumping to next/previous start/end of Methods
noremap <silent> ][ :call myFunctions#SectionJump('next', 'start')<CR>
noremap <silent> ]] :call myFunctions#SectionJump('next', 'end' )<CR>
noremap <silent> [[ :call myFunctions#SectionJump('prev', 'start')<CR>
noremap <silent> [] :call myFunctions#SectionJump('prev', 'end' )<CR>
noremap <silent> ]m :call myFunctions#MethodJump(']m')<CR>
noremap <silent> ]M :call myFunctions#MethodJump(']M')<CR>
noremap <silent> [m :call myFunctions#MethodJump('[m')<CR>
noremap <silent> [M :call myFunctions#MethodJump('[M')<CR>
""" Make Y consistent with C and D
nnoremap Y y$
""" Join line in Insert mode using <C-J>
inoremap <C-J> <C-\><C-O> J
""" Split line (sister to [J]oin lines)
nnoremap S i<CR><ESC>^mzgk:silent! s/\v +$//<CR>:noh<CR>`z:delm z<CR>
""" Break undo-sequence before deleting till start of line
inoremap <C-U> <C-G>u<C-U>
""" Remap ZQ to quit everything. I can always use :bd to delete a single buffer
nnoremap ZQ :qall!<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Indentation and styling {{{1
"""""""""""""""""""""""""""
""" Tab
" Shift-Tab to insert Tab else expand tabs to spaces
" Doesn't work with Snipmate or UltiSnips
"inoremap <S-Tab> <C-V><Tab>
" Insert tabs at start of line and spaces elsewhere
"inoremap <Tab> <C-R>=VaryTabs()<CR>
""" Reindent entire file.
" Using Preserve function ( defined in functions.vim ) restores cursor position
nnoremap <leader>= :call myFunctions#Preserve( 'normal! gg=G' )<CR>
""" Preserve visual block after indenting
vnoremap > >gv
vnoremap < <gv
""" Since tabularize mappings begin with a = we need to map == to itself so that vim doesn't wait at the end of the 2nd =
" to see if it's followed by a 't'
nnoremap == ==
vnoremap == =
""" Briefly show CursorLine and CursorColumn
nnoremap <silent> <F5> :call myFunctions#CursorBlind()<cr>
""" Moving text around
" Bubbling text
"nnoremap <silent> <C-Up> :m-2<CR>==
"vnoremap <silent> <C-Up> :m-2<CR>gv=gv
"imap <silent> <C-Up> <C-O>:m-2<CR><C-O>==
"nnoremap <silent> <C-Down> :m+1<CR>==
"vnoremap <silent> <C-Down> :m+1<CR>gv=gv
"imap <silent> <C-Down> <C-O>:m+1<CR><C-O>==
" Bubbling text (Using vim-unimpaired by tpope)
nmap <silent> <C-Up> [e==
vmap <silent> <C-Up> [egv=gv
imap <silent> <C-Up> <C-\><C-O>[e<C-\><C-O>==
nmap <silent> <C-Down> ]e==
vmap <silent> <C-Down> ]egv=gv
imap <silent> <C-Down> <C-\><C-O>]e<C-\><C-O>==
" Transposing words
"nnoremap <silent> <C-Left> :let ss=@/<CR>:let hls=&hls<CR>:<C-R>=hls?'se hls!':''<CR><CR>
" \"_yiw?\w\+\_W\+\%#<CR>:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR><C-O>
" \:let @/=ss<CR>:<C-R>=hls?'set hls':''<CR><CR>
"imap <silent> <C-Left> <C-O><C-Left>
"nnoremap <silent> <C-Right> :let ss=@/<CR>:let hls=&hls<CR>:<C-R>=hls?'se hls!':''<CR><CR>
" \"_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR><C-O>/\w\+\_W\+<CR>
" \:let @/=ss<CR>:<C-R>=hls?'set hls':''<CR><CR>
"imap <silent> <C-Right> <C-O><C-Right>
""" Panic Mode (rot13)
nnoremap <silent> <F9> :call myFunctions#Preserve( 'normal! ggg?G' )<CR>
""" Change font-size, line-spacing, window-size (May be set by vim-submode, hence the maparg() check)
nnoremap >l :<C-U>execute 'let &lines += ' ( v:count ? v:count : 1 )<CR>
nnoremap <l :<C-U>execute 'let &lines -= ' ( v:count ? v:count : 1 )<CR>
nnoremap >c :<C-U>execute 'let &columns += ' ( v:count ? v:count : 1 )<CR>
nnoremap <c :<C-U>execute 'let &columns -= ' ( v:count ? v:count : 1 )<CR>
nnoremap >s :<C-U>execute 'let &linespace += ' ( v:count ? v:count : 1 )<CR>
nnoremap <s :<C-U>execute 'let &linespace -= ' ( v:count ? v:count : 1 )<CR>
nnoremap >f :<C-U>IncFontSize<CR>
nnoremap <f :<C-U>DecFontSize<CR>
" Note: This overrides the default functionality of =fx. However, the same thing can be done by =_ or ==
nnoremap =f :set guifont=*<CR>
""" Fill Text Width
nnoremap <silent> <leader>fw :FTW<CR>
""" Toggle ColorColumn
nnoremap <silent> <expr> cok ':set colorcolumn=' . (&colorcolumn=='0' ? '+1' : 0) . '<CR>'
"
" Navigation {{{1
"
" % jumps from if-else-end while g% reverse jumps
nmap <A-%> g%
""" cscope mappings
" The following maps all invoke one of the following cscope search types:
" 'y' symbol: find all references to the token under cursor
" 'g' global: find global definition(s) of the token under cursor
" 'c' calls: find all calls to the function name under cursor
" 't' text: find all instances of the text under cursor
" 'e' egrep: egrep search for the word under cursor
" 'f' file: open the filename under cursor
" 'i' includes: find files that include the filename under cursor
" 'd' called: find functions that function under cursor calls
nnoremap <silent> <C-\> :call myFunctions#CscopeMap('l', 1)<CR>
nnoremap <silent> g<C-\> :call myFunctions#CscopeMap('l', 0)<CR>
""" Moving around in insert mode
inoremap <A-k> <Up>
inoremap <A-j> <Down>
inoremap <A-h> <Left>
inoremap <A-l> <Right>
""" Move by visual lines
noremap <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <expr> k (v:count == 0 ? 'gk' : 'k')
noremap gj j
noremap gk k
"noremap $ g$
"noremap g$ $
"noremap 0 g0
"noremap g0 0
nnoremap gm :call cursor(0, virtcol('$')/2)<CR>
"imap <C-Left> <C-O>B
"imap <C-Right> <C-O>W
""" View/scrolling
nnoremap zh 3zh
nnoremap zl 3zl
nnoremap <C-E> 3<C-E>
nnoremap <C-Y> 3<C-Y>
"nnoremap <C-J> <C-E>
"vnoremap <C-J> <C-E>
"nnoremap <C-K> <C-Y>
"vnoremap <C-K> <C-Y>
" Toggle the cursor line to be fixed in the middle of the screen
nnoremap <silent> <leader>zz :let &scrolloff=999-&scrolloff<CR>
" While opening a fold - put it on top and when closing, back to the middle.
nnoremap <silent> zc zczz" . float2nr(winheight(0)*0.2) . "\<Lt>C-E>"<CR>
nnoremap zo zozt
nnoremap <expr> <CR> foldlevel('.') ? 'za' : '<CR>'
""" Enable/disable/Toggle absolute/relative numbering
noremap <silent> <F2> :call myFunctions#CycleNumbering()<CR>
" Visually select the text that was last edited/pasted
nnoremap gV `[v`]
"
" Buffers, Windows, Tabs {{{1
"
""" Buffers
"nnoremap gb :<C-U>exec (v:count ? 'b '.v:count : 'bn')<cr>
nnoremap <S-Space> <C-^>
nnoremap <S-Del> :bd<CR>
nnoremap <S-BS> :bp<BAR>bd#<CR>
nnoremap <Space>b :ls<CR>:b<Space>
""" Windows
" Swap Windows
nnoremap <silent> <C-W><C-X> :call myFunctions#WindowSwap()<CR>
" Force close and re-split
nnoremap <silent> <C-W><S-V> <C-W><C-O><C-W><C-V>
nnoremap <silent> <C-W><S-S> <C-W><C-O><C-W><C-S>
" Close windows above/below/to the left/right of the current one
nnoremap <silent> <C-W><S-C>h <C-W><C-H><C-W>c
nnoremap <silent> <C-W><S-C>j <C-W><C-J><C-W>c
nnoremap <silent> <C-W><S-C>k <C-W><C-K><C-W>c
nnoremap <silent> <C-W><S-C>l <C-W><C-L><C-W>c
""" Tab operations
if v:version >= 700 && has('gui_running')
" Open file in new tab next to current tab
"nnoremap <silent> gt :let tabnum=tabpagenr()<CR><C-W>gf:execute 'silent! tabmove '.tabnum<CR>
" Move to
nnoremap <C-Home> :tabfirst<CR>
nnoremap <C-End> :tablast<CR>
"nnoremap <C-Tab> :tabnext<CR>
"nnoremap <C-S-Tab> :tabprev<CR>
" Move current tab to first position
nnoremap <C-S-Home> :tabmove 0<CR>
" Move current tab to last position
nnoremap <C-S-End> :tabmove<CR>
" Move current tab to the left
nnoremap <silent> <C-S-PageUp> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
" Move current tab to the right
nnoremap <silent> <C-S-PageDown> :execute 'silent! tabmove ' . tabpagenr()<CR>
" Toggle between all buffers and all tabs
nnoremap <silent> <expr> <F8> ( tabpagenr('$') == 1 ? ':tab ball<Bar>tabn' : ':tabo' ) . '<CR>'
endif
""" Command-line Window ( :h c_CTRL-F )
" Make Vim start in Insert mode in the command-line window.
"autocmd CmdwinEnter [/?] startinsert
" Make closing cmdline-window easier
autocmd CmdwinEnter * noremap <buffer> <ESC> <C-C><C-C>
" Persistent command-line window
autocmd CmdwinEnter * noremap <buffer> <S-CR> <CR>q:
" Unmap <CR> if used in any other mapping
"autocmd CmdwinEnter * unmap <CR>
" Remap <CR> after leaving the command-line window
"autocmd CmdwinLeave * nnoremap <CR> za
""" To make traversing up the directory tree easier in cmd-mode
cnoremap <C-W> <C-R>=myFunctions#CmdIsk(1)<CR><C-W><C-R>=myFunctions#CmdIsk(0)<CR>
"
" Search and replace {{{1
"
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Mode | Map | Description |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Normal | * # | Search word under cursor |
" | | g* g# | Search whole-word under cursor |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Normal | ,* ,# | Set search pattern without moving the cursor |
" | | ,g* ,g# | Set search pattern for whole-word without moving the cursor |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Normal | ,/ | Display all lines in current buffer containing the search term in a location-list |
" | | ,? | Display all lines in current buffer containing the previous search term in a location-list |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Normal | ,g/ | Display all lines in all buffers containing the search term in a quickfix-list |
" | | ,g? | Display all lines in all buffers containing the previous search term in a quickfix-list |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Normal | g/ | Grep all files containing the search term and show results in a quickfix-list |
" | | K | Grep all files containing the word under the cursor and show results in a quickfix-list |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Visual | / ? | Open search with visual selection but don't start searching |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Visual | * # | Start search with visual selection |
" | | g* g# | Start searching whole-word with visual selection |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Visual | & | Open substitute with visual selection |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Visual | ,* ,# | Set visual selection as the search pattern |
" | | ,g* ,g# | Set visual selection as the whole-word search pattern |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Visual | ,/ | Display all lines in current buffer containing the visual selection in a location-list |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Visual | ,g/ | Display all lines in window containing the visual selection in a quickfix-list |
" |--------+----------+--------------------------------------------------------------------------------------------|
" | Visual | g/ | Grep all files containing the visual selection and show results in a quickfix-list |
" |--------+----------+--------------------------------------------------------------------------------------------|
""" Use very-magic while searching (Perl-style regex)
nnoremap / /\v
nnoremap ? ?\v
cnoremap %s/ %s/\v
cnoremap .s/ .s/\v
xnoremap :s/ :s/\%V\v
xnoremap ;s/ :s/\%V\v
""" Set non-whole-word searches as default
nnoremap * g*
nnoremap g* *
nnoremap # g#
nnoremap g# #
""" Open search command with visual selection but don't start searching
vnoremap / <ESC>/\v<C-R>=escape( @*, '$%^&*=+<>()[]{}/' )<CR>
vnoremap ? <ESC>?\v<C-R>=escape( @*, '$%^&*=+<>()[]{}/' )<CR>
" This escape function is meant for use with normal substitution
"xnoremap / <ESC>/<C-R>=escape( @*, '$*[]\/' )<CR>
""" Start searching with visual selection. A bit redundant as only the <CR> at the end is extra
vnoremap * <ESC>/<C-R>=escape( @*, '$*[]\/' )<CR><CR>
vnoremap g* <ESC>/\<<C-R>=escape( @*, '$*[]\/' )<CR>\><CR>
vnoremap # <ESC>?<C-R>=escape( @*, '$*[]\/' )<CR><CR>
vnoremap g# <ESC>?\<<C-R>=escape( @*, '$*[]\/' )<CR>\><CR>
""" Start substitute with visual selection
" This escape function is meant for use with normal substitution
vnoremap & <ESC>:%s/<C-R>=escape( @*, '$*[]\\|\/' )<CR>/
" This escape function is meant only for use with verymagic substitution
"vnoremap & <ESC>:%s/\v<C-R>=escape( @*, '$%^*=+<>()[]{}&/' )<CR>/
""" Set search pattern without moving the cursor
nnoremap <silent> <leader>* :let @/=escape(expand('<cword>'),'$*[]/')<CR>
nnoremap <silent> <leader>g* :let @/='\<'.escape(expand('<cword>'),'$*[]/').'\>'<CR>
nnoremap <silent> <leader># :let @/=escape(expand('<cWORD>'),'$*[]/')<CR>
nnoremap <silent> <leader>g# :let @/='\<'.escape(expand('<cWORD>'),'$*[]/').'\>'<CR>
" Using <C-U> removes the range i.e. \<,\> from the ex command
vnoremap <silent> <leader>* :<C-U>let @/=escape(@*,'$*[]/')<CR>
vnoremap <silent> <leader>g* :<C-U>let @/='\<'.escape(@*,'$*[]/').'\>'<CR>
vnoremap <silent> <leader># :<C-U>let @/=escape(@*,'$*[]/')<CR>
vnoremap <silent> <leader>g# :<C-U>let @/='\<'.escape(@*,'$*[]/').'\>'<CR>
""" Find and show results in a LocationList (Buffer-specific)
nnoremap <silent> <leader>/ :call myFunctions#FindAndList('local', 'normal')<CR>
vnoremap <silent> <leader>/ :<C-U>call myFunctions#FindAndList('local', 'visual')<CR>
""" Open a LocationList for the last search.
nnoremap <silent> <leader>? :call myFunctions#FindAndList('local', 'prev')<CR>
""" Find and show results in a QuickfixList
nnoremap <silent> <leader>g/ :call myFunctions#FindAndList('global', 'normal')<CR>
vnoremap <silent> <leader>g/ :<C-U>call myFunctions#FindAndList('global', 'visual')<CR>
""" Open a LocationList for the last search.
nnoremap <silent> <leader>g? :call myFunctions#FindAndList('global', 'prev')<CR>
""" Grep
command! -nargs=+ -complete=file -bar Grep silent grep! <args>|cwindow 20|redraw!
nnoremap g/ :Grep<Space>
nnoremap K :Grep <C-R><C-W><CR>
""" Show tags having word under cursor
nnoremap <silent> [I :call myFunctions#IListpp()<CR>
""" Keep searches in middle of screen
nnoremap <silent> n :call myFunctions#SearchSaveAndRestore()<CR>/<CR>zvzz
nnoremap <silent> N :call myFunctions#SearchSaveAndRestore()<CR>?<CR>zvzz
""" Jump to corresponding <Tag> (AMD)
nmap <leader>< va><ESC>:<C-U>/<C-R>*<CR>
""" Clear contents of quickfix/location list
"augroup maps
" autocmd!
" autocmd BufEnter *
" \ if ( &bt=="quickfix" ) |
" \ nnoremap <silent> <buffer> <expr> <C-L> togglelist#IsLocationListBuffer() ? ":lex[]\<CR>" : ":cex[]\<CR>" |
" \ endif
"augroup END
""" Clear search string itself ( Save before clearing )
nnoremap <silent> <C-L> :call myFunctions#SearchSaveAndRestore()<Bar>let @/=""<CR><C-L>
"nnoremap <S-F5> :set hlsearch!<CR>:set hlsearch?<cr> " Use coh from Unimpaired
""" Remove trailing whitespace
nnoremap <silent> <leader>s<Space> :call myFunctions#Preserve( '%s/\v\s+$//' )<CR>
""" Swap around ( ==, ===, !=, !== ) in condition checks
"nnoremap <leader>ss :.s/\v([^( )]*)\s+(.)\=(\=)?\s+([^( )]*)/\4 \2=\3 \1/g<CR>:noh<CR>
"vnoremap <leader>ss :s/\v([^( )]*)\s+(.)\=(\=)?\s+([^( )]*)/\4 \2=\3 \1/g:noh<CR>
""" WRAP single-quotes in double-quotes and vice-versa
" For eg.
" alias pww=perl -lne 'if(/^\s*Working Dir: (\S+)/){$p=$1}if(/(?<=^ )Whacker\S+/){print "$p/$&"}'
" becomes
" alias pww=perl -lne 'if(/^\s*Working Dir: (\S+)/){$p=$1}if(/(?<=^ )Whacker\S+/){print "'"'"$p/$&"'"'"}'
" Enclose a double-quote in single-quotes
"vnoremap <leader>q[" :s/\%V"\+/"'&'"/g<Bar>noh<CR>
vnoremap [w" :s/\%V"\+/"'&'"/g<Bar>noh<Bar>call histdel('search', -1)<CR>``
" Derive a double-quote enclosed in single-quotes
vnoremap ]w" :s/\%V\v"'("+)'"/\1/g<Bar>noh<Bar>call histdel('search', -1)<CR>``
" Enclose a single-quote in double-quotes
vnoremap [w' :s/\%V'\+/'"&"'/g<Bar>noh<Bar>call histdel('search', -1)<CR>``
" Derive a single-quote enclosed in double-quotes
vnoremap ]w' :s/\%V\v'"('+)"'/\1/g<Bar>noh<Bar>call histdel('search', -1)<CR>``
""" Replace word under the cursor. Type replacement, press <ESC>. Use . to jump to next occurence of the word and repeat
""" Works only on recent patches, > 7xx
nnoremap g. :let @/=escape(expand('<cword>'),'$*[]/')<CR>cgn
"
" Misc {{{1
"
""" Show help on the word below cursor (Note: :h has be remapped to 'vert bo h')
nnoremap <silent> <S-F1> :h <C-R><C-W><CR>
imap <S-F1> <C-\><C-O><S-F1>
""" Ctrl+S functionality for save
nnoremap <silent> <C-S> :execute ':silent :wall!'<CR>
imap <silent> <C-S> <C-\><C-O><C-S>
""" Fullscreen
nnoremap <silent> <F11> :if &go=~#'m'<Bar>set go-=m<Bar>else<Bar>set go+=m<Bar>endif<CR>
""" Copy-paste simplified
nnoremap <silent> <A-y> "+y
vnoremap <silent> <A-y> "+y
nnoremap <silent> <A-p> "+p
""" Deleting to black hole register
nnoremap <silent> <A-d> "_d
vnoremap <silent> <A-d> "_d
""" Generate ctags
nnoremap <F12> :call myFunctions#UpdateTags()<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins {{{1
"""""""""""
"if !empty( filter( split(&rtp, ','), 'v:val =~ "neobundle.vim"')) | finish | endif
if !exists("*neobundle#is_sourced") | finish | endif
if neobundle#is_sourced('ack.vim')
nnoremap <Space>/ :Ack<Space>
nnoremap <Space>? :AckAdd<Space>
endif
if neobundle#is_sourced('CamelCaseMotion')
map <silent> <A-w> <Plug>CamelCaseMotion_w
map <silent> <A-b> <Plug>CamelCaseMotion_b
map <silent> <A-e> <Plug>CamelCaseMotion_e
omap <silent> i<A-w> <Plug>CamelCaseMotion_iw
xmap <silent> i<A-w> <Plug>CamelCaseMotion_iw
omap <silent> i<A-b> <Plug>CamelCaseMotion_ib
xmap <silent> i<A-b> <Plug>CamelCaseMotion_ib
omap <silent> i<A-e> <Plug>CamelCaseMotion_ie
xmap <silent> i<A-e> <Plug>CamelCaseMotion_ie
endif
if neobundle#is_sourced('ctrlp.vim')
map <Space> <Plug>[ctrlp]
nnoremap <silent> <Plug>[ctrlp]<Space> :CtrlPBuffer<CR>
nnoremap <silent> <Plug>[ctrlp]e :CtrlPCurWD<CR>
nnoremap <silent> <Plug>[ctrlp]f :CtrlP<CR>
nnoremap <silent> <Plug>[ctrlp]m :CtrlPMixed<CR>
nnoremap <silent> <Plug>[ctrlp]r :CtrlPMRU<CR>
nnoremap <silent> <Plug>[ctrlp]t :CtrlPTag<CR>
if neobundle#is_installed('ctrlp-funky')
nnoremap <silent> <Plug>[ctrlp]o :CtrlPFunky<CR>
endif
if neobundle#is_installed('vim-ctrlp-cmdpalette')
nnoremap <silent> <Plug>[ctrlp]; :CtrlPCmdPalette<CR>
endif
if neobundle#is_installed('vim-ctrlp-tjump')
nnoremap <silent> <Plug>[ctrlp]] :CtrlPtjump<CR>
vnoremap <silent> <Plug>[ctrlp]] :CtrlPtjumpVisual<CR>
endif
let g:ctrlp_prompt_mappings = {
\ 'PrtSelectMove("j")': ['<C-J>'],
\ 'PrtSelectMove("k")': ['<C-K>'],
\ 'PrtHistory(-1)': ['<C-N>', '<Down>'],
\ 'PrtHistory(1)': ['<C-P>', '<Up>'],
\ 'ToggleType(1)': ['<C-F>', '<C-L>'],
\ 'ToggleType(-1)': ['<C-B>', '<C-H>'],
\ 'PrtCurLeft()': ['<Left>'],
\ 'PrtCurRight()': ['<Right>'],
\ }
endif
if neobundle#is_sourced('Command-T')
nnoremap <silent> <Space><Space> :CommandTBuffer<CR>
nnoremap <silent> <Space>f :CommandT<CR>
endif
if neobundle#is_sourced('vim-fswitch')
nnoremap <silent> goff :FSHere<CR>
nnoremap <silent> <S-CR> :FSHere<CR>
nnoremap <silent> gofF :let g:fsnonewfiles=0 <Bar> FSHere <Bar> unlet g:fsnonewfiles<CR>
nnoremap <silent> gofh :FSLeft<CR>
nnoremap <silent> gofj :FSBelow<CR>
nnoremap <silent> gofk :FSAbove<CR>
nnoremap <silent> gofl :FSRight<CR>
nnoremap <silent> gofH <C-W><C-O>:FSSplitLeft<CR>
nnoremap <silent> gofJ <C-W><C-O>:FSSplitBelow<CR>
nnoremap <silent> gofK <C-W><C-O>:FSSplitAbove<CR>
nnoremap <silent> gofL <C-W><C-O>:FSSplitRight<CR>
endif
if neobundle#is_installed('gundo.vim')
nnoremap coU :GundoToggle<CR>
endif
if neobundle#is_sourced('incsearch.vim')
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
endif
if neobundle#is_installed('indentLine')
nnoremap coI :IndentLinesToggle<CR>
endif
if neobundle#is_installed('vim-indent-guides')
nnoremap coI :IndentGuidesToggle<CR>
endif
if neobundle#is_sourced('nerdcommenter')
nmap <silent> gcc <Plug>NERDCommenterAlignBoth
vmap <silent> gcc <Plug>NERDCommenterAlignBoth
nmap <silent> gcs <Plug>NERDCommenterSexy
vmap <silent> gcs <Plug>NERDCommenterSexy
nmap <silent> gc$ <Plug>NERDCommenterToEOL
vmap <silent> gc$ <Plug>NERDCommenterToEOL
nmap <silent> gc<Space> <Plug>NERDCommenterInvert
vmap <silent> gc<Space> <Plug>NERDCommenterInvert
nmap <silent> gcu <Plug>NERDCommenterUncomment
vmap <silent> gcu <Plug>NERDCommenterUncomment
nmap <silent> gca <Plug>NERDCommenterAltDelims
nmap <silent> gcA <Plug>NERDCommenterAppend
nmap <silent> gcy <Plug>NERDCommenterYank
vmap <silent> gcy <Plug>NERDCommenterYank
endif
if neobundle#is_sourced('neocomplcache')
inoremap <expr> <C-H> neocomplcache#undo_completion()
"inoremap <expr> <C-G> neocomplcache#complete_common_string()
endif
if neobundle#is_sourced('vim-notes')
"inoremap <C-T> <C-O>:call xolox#notes#indent_list(1, line('.'), line('.'))<CR>
"inoremap <C-D> <C-O>:call xolox#notes#indent_list(-1, line('.'), line('.'))<CR>
"nnoremap <C-]> :SearchNotes<CR>
endif
if neobundle#is_installed('rainbow_parentheses.vim')
nnoremap <silent> <F3> :RainbowParenthesesActivate<CR>
\ :RainbowParenthesesLoadRound<CR>
\ :RainbowParenthesesLoadSquare<CR>
\ :RainbowParenthesesLoadBraces<CR>
nnoremap <S-F3> :RainbowParenthesesToggleAll<CR>
endif
if neobundle#is_installed('rainbow')
nnoremap coR :RainbowToggle<CR>
endif
if neobundle#is_sourced('vim-repeat')
" This should happen automatically but it isn't
"call repeat#createmaps()
nnoremap <silent> <C-R> :<C-U>call repeat#wrap('U',v:count)<CR>
nnoremap <silent> U :<C-U>call repeat#wrap("\<Lt>C-R>",v:count)<CR>
endif
if neobundle#is_sourced('vim-signature')
let i=1
while i <= 9
execute 'nnoremap <silent> ]' . i . ' :<C-U>call signature#marker#Goto("next", ' . i .', v:count)<CR>'
execute 'nnoremap <silent> [' . i . ' :<C-U>call signature#marker#Goto("prev", ' . i .', v:count)<CR>'
let i += 1
endwhile
endif
if neobundle#is_sourced('vim-sneak')
" Disable the 's' map and next/prev maps
map gs <Plug>Sneak_s
map gS <Plug>Sneak_S
" 1-character _inclusive_ Sneak (for enhanced 'f')
map f <Plug>Sneak_f
map F <Plug>Sneak_F
" 1-character _exclusive_ Sneak (for enhanced 't')
map t <Plug>Sneak_t
map T <Plug>Sneak_T
" Next/Prev Sneak
map \ <Plug>SneakNext
map \| <Plug>SneakPrevious
endif
if neobundle#is_installed( 'vim-submode' )
call submode#enter_with( 'WinResize', 'n', '', '<C-W><' , '<C-W><' )
call submode#enter_with( 'WinResize', 'n', '', '<C-W>>' , '<C-W>>' )
call submode#map ( 'WinResize', 'n', '', '<' , '<C-W><' )
call submode#map ( 'WinResize', 'n', '', '=' , '<C-W>=' )
call submode#map ( 'WinResize', 'n', '', '>' , '<C-W>>' )
call submode#enter_with( 'WinResize', 'n', '', '<C-W>+' , '<C-W>+' )
call submode#enter_with( 'WinResize', 'n', '', '<C-W>-' , '<C-W>-' )
call submode#map ( 'WinResize', 'n', '', '+' , '<C-W>+' )
call submode#map ( 'WinResize', 'n', '', '=' , '<C-W>=' )
call submode#map ( 'WinResize', 'n', '', '-' , '<C-W>-' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W>h' , '<C-W>h' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W>j' , '<C-W>j' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W>k' , '<C-W>k' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W>l' , '<C-W>l' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W><C-H>' , '<C-W><C-H>' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W><C-J>' , '<C-W><C-J>' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W><C-K>' , '<C-W><C-K>' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W><C-L>' , '<C-W><C-L>' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W><Up>' , '<C-W><Up>' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W><Down>' , '<C-W><Down>' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W><Left>' , '<C-W><Left>' )
"call submode#enter_with( 'WinMove' , 'n', '', '<C-W><Right>', '<C-W><Right>' )
"call submode#map ( 'WinMove' , 'n', '', 'h' , '<C-W>h' )
"call submode#map ( 'WinMove' , 'n', '', 'j' , '<C-W>j' )
"call submode#map ( 'WinMove' , 'n', '', 'k' , '<C-W>k' )
"call submode#map ( 'WinMove' , 'n', '', 'l' , '<C-W>l' )
"call submode#map ( 'WinMove' , 'n', '', '<C-H>' , '<C-W><C-H>' )
"call submode#map ( 'WinMove' , 'n', '', '<C-J>' , '<C-W><C-J>' )
"call submode#map ( 'WinMove' , 'n', '', '<C-K>' , '<C-W><C-K>' )
"call submode#map ( 'WinMove' , 'n', '', '<C-L>' , '<C-W><C-L>' )
"call submode#map ( 'WinMove' , 'n', '', '<Up>' , '<C-W><Up>' )
"call submode#map ( 'WinMove' , 'n', '', '<Down>' , '<C-W><Down>' )
"call submode#map ( 'WinMove' , 'n', '', '<Left>' , '<C-W><Left>' )
"call submode#map ( 'WinMove' , 'n', '', '<Right>' , '<C-W><Right>' )
"call submode#enter_with( 'Indent' , 'n', '', '>>' , '>>' )
"call submode#enter_with( 'Indent' , 'n', '', '<<' , '<<' )
"call submode#map ( 'Indent' , 'n', '', '>' , '>>' )
"call submode#map ( 'Indent' , 'n', '', '<' , '<<' )
"call submode#enter_with( 'WinCycle' , 'n', '', '<C-W><C-W>' , '<C-W><C-W>' )
"call submode#enter_with( 'WinCycle' , 'n', '', '<C-W>w' , '<C-W>w' )
"call submode#enter_with( 'WinCycle' , 'n', '', '<C-W>W' , '<C-W>W' )
"call submode#map ( 'WinCycle' , 'n', '', '<C-W>' , '<C-W><C-W>' )
"call submode#map ( 'WinCycle' , 'n', '', 'w' , '<C-W>w' )
"call submode#map ( 'WinCycle' , 'n', '', 'W' , '<C-W>W' )
" Custom Maps
"nnoremap <Plug>IncLines :<C-U>let &lines += 1<CR>
"nnoremap <Plug>DecLines :<C-U>let &lines -= 1<CR>
"call submode#enter_with( 'ResizeLines', 'n', 'r', '>l', '<Plug>IncLines' )
"call submode#enter_with( 'ResizeLines', 'n', 'r', '<l', '<Plug>DecLines' )
"call submode#map ( 'ResizeLines', 'n', 'r', '>' , '<Plug>IncLines' )
"call submode#map ( 'ResizeLines', 'n', 'r', '<' , '<Plug>DecLines' )
"nnoremap <Plug>IncColumns :<C-U>let &columns += 1<CR>
"nnoremap <Plug>DecColumns :<C-U>let &columns -= 1<CR>
"call submode#enter_with( 'ResizeColumns', 'n', 'r', '>c', '<Plug>IncColumns' )
"call submode#enter_with( 'ResizeColumns', 'n', 'r', '<c', '<Plug>DecColumns' )
"call submode#map ( 'ResizeColumns', 'n', 'r', '>' , '<Plug>IncColumns' )
"call submode#map ( 'ResizeColumns', 'n', 'r', '<' , '<Plug>DecColumns' )
"nnoremap <Plug>IncLineSpace :<C-U>let &linespace += 1<CR>
"nnoremap <Plug>DecLineSpace :<C-U>let &linespace -= 1<CR>
"call submode#enter_with( 'ResizeLsp', 'n', 'r', '>s', '<Plug>IncLineSpace' )
"call submode#enter_with( 'ResizeLsp', 'n', 'r', '<s', '<Plug>DecLineSpace' )
"call submode#map ( 'ResizeLsp', 'n', 'r', '>' , '<Plug>IncLineSpace' )
"call submode#map ( 'ResizeLsp', 'n', 'r', '<' , '<Plug>DecLineSpace' )
"nnoremap <Plug>IncFontSize :<C-U>IncFontSize<CR>
"nnoremap <Plug>DecFontSize :<C-U>DecFontSize<CR>
"call submode#enter_with( 'ResizeFont', 'n', 'r', '<f', '<Plug>DecFontSize' )
"call submode#enter_with( 'ResizeFont', 'n', 'r', '>f', '<Plug>IncFontSize' )
"call submode#map ( 'ResizeFont', 'n', 'r', '<' , '<Plug>DecFontSize' )
"call submode#map ( 'ResizeFont', 'n', 'r', '>' , '<Plug>IncFontSize' )
endif
if neobundle#is_sourced('switch.vim')
nnoremap <M-s> :Switch<CR>
endif
if neobundle#is_sourced('syntastic')
nnoremap cos :SyntasticToggleMode<CR>
nnoremap ysc :SyntasticCheck<CR>
endif
if neobundle#is_installed('vim-table-mode')
let g:table_mode_map_prefix = '<Plug>[table]'
nnoremap coB :TableModeToggle<CR>
endif
if neobundle#is_sourced('tabular')
noremap =tt :Tabularize<Space>/
noremap =t] :Tabularize /\m]/l0r1<CR> //
noremap =t<Bar> :Tabularize /\|<CR>
noremap =t(0 :Tabularize /\v^[^(]*\zs\(/l0r0<CR>
noremap =t(1 :Tabularize /\v^[^(]*\zs\(/l0r1<CR>
noremap =t)0 :Tabularize /\v\)\ze[^)]*$/l0r0<CR>
noremap =t)1 :Tabularize /\v\)\ze[^)]*$/l1r0<CR>
noremap =tb :Tabularize align_braces<CR>
noremap =t, :Tabularize /,/l0r1<CR>
noremap =t= :Tabularize assignment<CR>
noremap =t?: :Tabularize ternary_operator<CR>
noremap =t/ :Tabularize trailing_c_comments<CR>
noremap =t<Space> :Tabularize align_words<CR>
endif
if neobundle#is_sourced('tagbar')
nnoremap coT :TagbarToggle<CR>
endif
if neobundle#is_sourced('vim-textobj-line')
omap a_ <Plug>(textobj-line-a)
omap i_ <Plug>(textobj-line-i)
xmap a_ <Plug>(textobj-line-a)
xmap i_ <Plug>(textobj-line-i)
endif
if neobundle#is_installed('vim-togglelist')
nnoremap coL :ToggleLL<CR>
nnoremap coC :ToggleQF<CR>
endif
if neobundle#is_sourced('unite.vim')
function! UniteMappings()
imap <silent> <buffer> <C-J> <Plug>(unite_select_next_line)
imap <silent> <buffer> <C-K> <Plug>(unite_select_previous_line)
imap <silent> <buffer> <C-N> <C-O><Plug>(unite_rotate_next_source)
imap <silent> <buffer> <C-P> <C-O><Plug>(unite_rotate_previous_source)
" Exit Unite buffer
nmap <silent> <buffer> <Esc> <Plug>(unite_exit)
nmap <silent> <buffer> <C-C> <Plug>(unite_exit)
imap <silent> <buffer> <C-C> <Plug>(unite_exit)
" Use <Tab> to narrow down paths and open files
nmap <silent> <buffer> <Tab> <Plug>(unite_do_default_action)
imap <silent> <buffer> <Tab> <Plug>(unite_do_default_action)
" Use <C-Tab> to choose custom actions
imap <silent> <buffer> <C-Tab> <Plug>(unite_choose_action)
" Open selected file in a split
nnoremap <silent> <buffer> <expr> <C-S> unite#do_action('below')
nnoremap <silent> <buffer> <expr> <C-V> unite#do_action('right')
inoremap <silent> <buffer> <expr> <C-S> unite#do_action('below')
inoremap <silent> <buffer> <expr> <C-V> unite#do_action('right')
endfunction
nmap <Space> <Plug>(unite)
nnoremap <Plug>(unite)u :<C-U>Unite
nnoremap <silent> <Plug>(unite)<Space> :Unite -toggle -buffer-name=Buffers buffer <CR>
nnoremap <silent> <C-Space> :Unite -toggle -buffer-name=Buffers buffer_tab<CR>
nnoremap <silent> <Plug>(unite)b :Unite -toggle -buffer-name=Bookmarks bookmark <CR>
nnoremap <silent> <Plug>(unite)e :Unite -toggle -buffer-name=Files file <CR>
nnoremap <silent> <Plug>(unite)l :Unite -toggle -buffer-name=LustyJuggler -quick-match buffer<CR>
nnoremap <silent> <Plug>(unite)m :Unite -toggle -buffer-name=Mixed buffer bookmark file_mru file_rec/async<CR>
nnoremap <silent> <Plug>(unite)o :Unite -toggle -buffer-name=Outline outline<CR>
nnoremap <silent> <Plug>(unite)r :Unite -toggle -buffer-name=MRU file_mru<CR>
nnoremap <silent> <Plug>(unite)y :Unite -toggle -buffer-name=Yanks history/yank<CR>
" Search the PWD if a root marker is not found
nnoremap <silent> <Plug>(unite)f :execute 'Unite -toggle -buffer-name=FileRec bookmark file_rec/async:' . unite#util#path2project_directory(getcwd())<CR>
" Unite-Grep:
nnoremap <silent> <Plug>(unite)/ :execute 'Unite -toggle -buffer-name=Grep -no-quit grep:' . unite#util#path2project_directory(getcwd())<CR>
nnoremap <silent> <Plug>(unite)? :execute 'Unite -toggle -buffer-name=Grep -no-quit grep:' . unite#util#path2project_directory(getcwd()) . ' -resume'<CR>
command! -nargs=0 NeoBundleInstall Unite neobundle/install -no-start-insert
command! -nargs=0 NeoBundleUpdate Unite neobundle/update -no-start-insert
endif
if neobundle#is_sourced('yankring')
nnoremap <leader>sy :YRShow<CR>
" Yank registers
" As Yankring remaps Y internally, have to call its built-in plugin to map Y
function! YRRunAfterMaps()
nnoremap <silent> Y :<C-U>YRYankCount 'y$'<CR>
endfunction
endif
Jump to Line
Something went wrong with that request. Please try again.