On 2006-04-28, Suresh Govindachar <[EMAIL PROTECTED]> wrote:
>   > Gerald Lai sent on Thu, 27 Apr 2006 17:44:05 -0700 (PDT):
>   >> On Thu, 27 Apr 2006, Suresh Govindachar wrote:
>   >>
>   >> Hello,
>   >>
>   >>  Why does the following _single_ line map
>   >>  generate the E10 error?:
>   >>
>   >>  nmap <space> :let 
> @a=substitute(getline('.'),'\(^.*|\s*\)\|\(\s\s*$\)','','g')
>   
>   Note that error E10 concerns viml line continuation 
>   but the preceding is all one line -- does not have viml
>   line continuation.

Actually, the description of E10 says it is _often_ caused by 
command-line continuation; it does not say that that is the only 
cause.

> 
>   >>  How would it be fixed?

I played with this a little bit before seeing Gerald's reply and 
discovered, as he pointed out, that the problem is with the '|'.  I 
worked around it by adding backslashes until it worked.  I found I 
had to escape the first one in the pattern to avoid the error, then 
figured I would have to escape the second one twice to make vim see 
it as '\|'.

nmap <space> :let 
@a=substitute(getline('.'),'\(^.*\|\s*\)\\|\(\s\s*$\)','','g')<CR>

And as Gerald said, it needs a "<CR>" at the end, too.

>   > 
>   > What do you intend to do with the mapping?
> 
>   The line would have several '|' characters in it;  I want @a to 
>   contain the the stuff after the very last '|' but without any
>   leading or trailing white space in the captured stuff:
>   So, for example, if the line was: 
> 
>     stuff | more stuff | want this gold      
> 
>   then @a should contain "want this gold" (without quotes)

Now that I know what you intended this to do, I tested my version 
and it seems to work.

I wish I had a better understanding of when vim ignores quotes and 
instead requires backslashes to escape |'s.

HTH,
Gary

-- 
Gary Johnson                 | Agilent Technologies
[EMAIL PROTECTED]     | Wireless Division
                             | Spokane, Washington, USA

Reply via email to