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')

 How would it be fixed?

What do you intend to do with the mapping?

First, replace all "|" with "<Bar>":

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

"|"s are used as the command separator in the :cmdline.

I think you'd want the first "<Bar>" to be escaped with a backslash \ .
Also, put "<CR>" at the end:

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

Simplifying the regex yields:

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

HTH.
--
Gerald

Reply via email to