On Friday, March 22, 2013 7:42:41 AM UTC-5, Marco wrote:
> Since vim has an understanding of
> functions (determined by the outermost brace pair probably) why is
> there no built in way to use this information for a motion?
> 

I don't think Vim does have an understanding of functions. It knows about { or 
} in the first column (the [[ and ][ motions which you're using in your 
mapping).

Also, your example mapping:

  onoremap if :<C-U>normal! [[vi{<cr>

On your example text:

template <typename Stream> 
void do_read( Stream& stream, std::vector<char>& buf ) 
{
  boost::asio::async_read( 
    stream, boost::asio::buffer( buf ), boost::bind( read_handler )); 

  stream.get_io_service().reset(); 
  stream.get_io_service().run(); 

  std::cout << "done" << std::endl; 
}

Only selects 7 lines, unless there is a space character after the opening {.

...I see why.

I have 'selection' set to "exclusive". If I change it to "inclusive" then I get 
8 lines.

Looking at WHAT gets copied with yif leads me to the following solution:

  onoremap if :<C-U>normal! [[vi{h<cr>

This will work if 'selection' is set to "inclusive". If "exclusive" then you 
need to leave off the h as you did before. If you want to make your mapping 
generic you'll probably need to use an <expr> mapping which checks the value of 
the 'selection' option.

-- 
-- 
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/groups/opt_out.


Reply via email to