On Fri, Nov 28, 2008 at 10:54 PM, Tim Johnson wrote:
>
> Using vim 7.1 (huge) on kubuntu 7.10
>
> Executing the following
> ?[\|(\|{
> Gives me the expected results. I.E.
> The cursor is placed at the closest previous '[' or '(' or '{'
>
> Executing the following
> /]\|)\|}
> Gives me the expected results. I.E.
> The cursor is placed on the closest next ']' or ')' or '}'
Here, you're using the thing mentioned at :help / or :help ? - they
are characterwise searches.
> Yet these two functions:
> function! PreviousDelimiter()
> execute '?[\|(\|{'
> execute ':nohls'
> endfunction
> " and
> function! PreviousDelimiter()
> execute '?[\|(\|{'
> execute ':nohls'
> endfunction
>
> yield unexpected results. In each case, when the function
> is called, the cursor is placed at the beginning of the line
> of the first successful match, rather than on the target char.
>
> Your help is appreciated and even moreso, pointers to
> discussions on the relevant subjects.
And here, you're using the thing mentioned at :help :/ and :help :?
- they are linewise searches that specify a line address. To get the
behavior that you want, either use the search() function, or use
"norm!" to make vim behave as though you typed the ? normal mode
command instead of the ? ex-mode command.
exe 'norm! ?[\|(\|{' . "\<CR>"
or
exe "norm! ?[\\|(\\|{\<CR>"
~Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---