Last active
December 17, 2015 20:39
-
-
Save mislav/5669229 to your computer and use it in GitHub Desktop.
Defines the `;` motion to select whatever object starts below the cursor
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
" Defines `;` to select the object currently below the cursor. | |
" Intended for use when positioned above an opening or closing quote/bracket. | |
" | |
" Examples: | |
" | |
" Move to a string, change inside it: f" ci; | |
" Search for a bracket, delete whole object: /{ da; | |
onoremap a; :<c-u>call <SID>TextObjectCursorCharacter('a')<cr> | |
xnoremap a; :<c-u>call <SID>TextObjectCursorCharacter('a')<cr> | |
onoremap i; :<c-u>call <SID>TextObjectCursorCharacter('i')<cr> | |
xnoremap i; :<c-u>call <SID>TextObjectCursorCharacter('i')<cr> | |
function! s:TextObjectCursorCharacter(motion) | |
let char = getline('.')[col('.')-1] | |
exec 'normal! v' . a:motion . char | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment