Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add `;` object trigger to affect text object under cursor

Defines `;` to select the object currently below the cursor.
Intended for use when positioned above an opening or closing quote/bracket.
  • Loading branch information...
commit 0c630e1ecb7ae25a5c6fc6dda3521cca04ad4cb1 1 parent e8a57e7
@mislav authored
Showing with 17 additions and 0 deletions.
  1. +17 −0 plugin/change_current_object.vim
View
17 plugin/change_current_object.vim
@@ -0,0 +1,17 @@
+" 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
Please sign in to comment.
Something went wrong with that request. Please try again.