Re: escape / after \V
- On 29/07/12 20:11, Gary Johnson wrote:
> On 2012-07-29, Bee wrote:Or, you could use any character instead of / if there is one which you
>> escape / after \V
>> :help \V
>> Use of "\V" means that in the pattern after it only the backslash has
>> a special meaning. "very nomagic"
>> I have a function:
>> function! Visual2Highlight()
>> let @/ = '\c\V' . substitute(escape(@@,'/\'),'\n','\\n','g')
>> execute '3match User1 /' . @/ . '/'
>> vnoremap <F12> y:call Visual2Highlight()<cr>
>> If / is NOT included in escape(@@,'/\') it does NOT work.
>> If I use the function on line(s) that have a / then I get an error:
>> Example: Visually select this whole line:
>> " multi-line visual to /highlight
>> Error detected while processing function Visual2Highlight:
>> line 2:
>> E488: Trailing characters: 3match User1 /\c\V" multi-line visual to /
>> It looks like / still has special meaning.
>> What is happening?
> In the 3match command, you are using / to delimit the pattern, so
> any / within the pattern will have to be escaped, otherwise the
> first one will terminate the pattern and the following characters
> will be seen as "trailing characters".
know will not happen in the pattern, for instance
exec '3match User1 £' . @/ . '£'
if you know that there will be no £ sign in what you just put into @/ in
the preceding :let statement.
"I'd love to go out with you, but I'm staying home to work on my
cottage cheese sculpture."
You received this message from the "vim_dev" 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