Saturday, June 14, 2014

Hep on writing custom text object

Dear Vim experts,

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?

Cheers!

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: