Added steve losh next-textobject functionality. vinb to visual inside next set of parens
This commit is contained in:
parent
4a2bd58c99
commit
4bb23eba41
@ -313,6 +313,7 @@ Included vim plugins
|
||||
* textobj-datetime - gives you 'da' (date), 'df' (date full) and so on text objects. useable with all standard verbs
|
||||
* vim-textobj-entire - gives you 'e' for entire document. so vae (visual around entire document), and etc
|
||||
* vim-textobj-rubysymbol - gives you ':' textobj. so va: to select a ruby symbol. da: to delete a symbol..etc
|
||||
* next-textobject - from Steve Losh, ability to use 'n' such as vinb (visual inside (n)ext set of parens)
|
||||
|
||||
**Utils**
|
||||
|
||||
|
29
vim/plugin/settings/next-textobject.vim
Normal file
29
vim/plugin/settings/next-textobject.vim
Normal file
@ -0,0 +1,29 @@
|
||||
" Stolen from Steve Losh
|
||||
" https://bitbucket.org/sjl/dotfiles/src/tip/vim/.vimrc
|
||||
"
|
||||
" Motion for "next/last object". For example, "din(" would go to the next "()"
|
||||
" pair and delete its contents.
|
||||
onoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
|
||||
xnoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
|
||||
onoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
|
||||
xnoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
|
||||
|
||||
onoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
|
||||
xnoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
|
||||
onoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
|
||||
xnoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
|
||||
|
||||
function! s:NextTextObject(motion, dir)
|
||||
let c = nr2char(getchar())
|
||||
|
||||
if c ==# "b"
|
||||
let c = "("
|
||||
elseif c ==# "B"
|
||||
let c = "{"
|
||||
elseif c ==# "d"
|
||||
let c = "["
|
||||
endif
|
||||
|
||||
exe "normal! ".a:dir.c."v".a:motion.c
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user