Asis, On Saturday, June 14, 2014 5:30:15 PM UTC+2, Asis Hallab wrote: > I am trying to write a custom text object. I call it "f" for function > and it should match function in the functional programming language R. > My attempts are based on vim tip > http://vim.wikia.com/wiki/Creating_new_text_objects > > vnoremap af :<C-U>silent! normal! ?\S\+\s\+<-\s\+function<CR>/^\s*} > > omap af :normal Vaf<CR> > > In spite of the fact that the normal \S\+\s\+<-\s\+function does go > back to a function declaration the first of the above mappings only > works until the closing }. > > If for example my cursor is at the beginning of line 2 of the > following function and I press daf in normal mode > > 1: myFunk <- function( x ) { > 2: x^2 + 3 * x^35 > 3: srqt(x) > 4: } > > only line 1 is retained. > > Any ideas?
many people like to rely on the 'textobj-user' plugin framework for creating new text objects. https://github.com/kana/vim-textobj-user https://github.com/kana/vim-textobj-user/wiki The 'textobj-function' plugin was specifically created to enable selecting function text objects with af/if in any language. https://github.com/kana/vim-textobj-function Maybe you'll find this useful. -- David -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
