Re: vim Syntax Highlighting

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: vim Syntax Highlighting

Rene-48
Thanks, I nearly done it:
syn region    cppRawString  
  start=+R"\([a-zA-Z0-9\_\{\}\]\#\(\)\<\>\%\:\;\.\?\*\+\-\/\^\&\|\~\!\=\,\\\"\']\)*\[+ end=+\]\1"+ contains=cSpecial,cFormat,@Spell

Just the problem is, it seems like I couldn't use the grouped atom in
the start pattern for use in the end pattern..

Vim is saying: "Illegal back reference" because I use \1 in the end
pattern..
The start pattern is correct, I tested it, only the end pattern isn't
working.

How can I get the group-match of the start pattern and use it in the end
pattern?

Is this even possible right now? If it wasn't possible C++ raw strings
would be impossible to implement :-(


Kind Regards, René


Am 04.03.2010 10:02, schrieb Lech Lorens:
> Syntax for C++ is defined in $VIMRUNTIME/syntax/cpp.vim
> The $VIMRUNTIME environment variable is defined by Vim.
>
>    

--
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
Reply | Threaded
Open this post in threaded view
|

Re: vim Syntax Highlighting

Lech Lorens
On 4 March 2010 10:56, Rene <[hidden email]> wrote:

> Thanks, I nearly done it:
> syn region    cppRawString
>  start=+R"\([a-zA-Z0-9\_\{\}\]\#\(\)\<\>\%\:\;\.\?\*\+\-\/\^\&\|\~\!\=\,\\\"\']\)*\[+
> end=+\]\1"+ contains=cSpecial,cFormat,@Spell
>
> Just the problem is, it seems like I couldn't use the grouped atom in the
> start pattern for use in the end pattern..
>
> Vim is saying: "Illegal back reference" because I use \1 in the end
> pattern..
> The start pattern is correct, I tested it, only the end pattern isn't
> working.
>
> How can I get the group-match of the start pattern and use it in the end
> pattern?
>
> Is this even possible right now? If it wasn't possible C++ raw strings would
> be impossible to implement :-(
>
>
> Kind Regards, René

:help :syn-ext-match

HTH

BTW, please do not top-post on this group.

--
Regards,
Lech Lorens

--
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
Reply | Threaded
Open this post in threaded view
|

Re: vim Syntax Highlighting

Charles Campbell
In reply to this post by Rene-48
Lech Lorens wrote:

> On 3 March 2010 21:29, Rene <[hidden email]> wrote:
>  
>> Hello vim-dev list,
>>
>> I recently switched to Ubuntu Lynx to easily use 'gcc-snapshot' which offers
>> C++0x support and especially
>> the so called raw strings.
>>
>> The vim package bundled with Lynx must be one of the newest but it doesn't
>> offer syntax highlighting for
>> raw strings. :'-(
>>
>> Where and how to edit the syntax highlighting system? Sadly my Google Search
>> didn't help me.
>>
>> Please give me some links to be able to start editing the syntax
>> highlighting system and if I succeed I'll post you
>> a patch to enable proper C++0x raw string highlighting ;-)
>>    
>
> Syntax for C++ is defined in $VIMRUNTIME/syntax/cpp.vim
> The $VIMRUNTIME environment variable is defined by Vim.
>
>  
To make a custom C++ syntax file, I suggest:

mkdir -p $HOME/.vim/syntax
cp $VIMRUNTIME/syntax/cpp.vim $HOME/.vim/syntax

and modify $HOME/.vim/syntax/cpp.vim to suit.

Regards,
Chip Campbell


--
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
Reply | Threaded
Open this post in threaded view
|

Re: vim Syntax Highlighting

Charles Campbell
In reply to this post by Rene-48
Rene wrote:

> Thanks, I nearly done it:
> syn region    cppRawString  
>  start=+R"\([a-zA-Z0-9\_\{\}\]\#\(\)\<\>\%\:\;\.\?\*\+\-\/\^\&\|\~\!\=\,\\\"\']\)*\[+
> end=+\]\1"+ contains=cSpecial,cFormat,@Spell
>
> Just the problem is, it seems like I couldn't use the grouped atom in
> the start pattern for use in the end pattern..
>
> Vim is saying: "Illegal back reference" because I use \1 in the end
> pattern..
> The start pattern is correct, I tested it, only the end pattern isn't
> working.
>
> How can I get the group-match of the start pattern and use it in the
> end pattern?
>
> Is this even possible right now? If it wasn't possible C++ raw strings
> would be impossible to implement :-(
Look into using  \z(...\)  and \z1 .

Regards,
Chip Campbell

--
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
Reply | Threaded
Open this post in threaded view
|

Re: vim Syntax Highlighting

James Vega-3
In reply to this post by Charles Campbell
On Thu, Mar 4, 2010 at 11:36 AM, Charles Campbell
<[hidden email]> wrote:
> To make a custom C++ syntax file, I suggest:
>
> mkdir -p $HOME/.vim/syntax
> cp $VIMRUNTIME/syntax/cpp.vim $HOME/.vim/syntax
>
> and modify $HOME/.vim/syntax/cpp.vim to suit.

It depends on the complexity of what's being added.  If it can stand on
its own, $HOME/.vim/after/syntax/cpp.vim would likely be better so
future updates to upstream's cpp.vim aren't lost.

--
James
GPG Key: 1024D/61326D40 James Vega <[hidden email]>

--
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
Reply | Threaded
Open this post in threaded view
|

Re: vim Syntax Highlighting

Charles Campbell
James Vega wrote:

> On Thu, Mar 4, 2010 at 11:36 AM, Charles Campbell
> <[hidden email]> wrote:
>  
>> To make a custom C++ syntax file, I suggest:
>>
>> mkdir -p $HOME/.vim/syntax
>> cp $VIMRUNTIME/syntax/cpp.vim $HOME/.vim/syntax
>>
>> and modify $HOME/.vim/syntax/cpp.vim to suit.
>>    
>
> It depends on the complexity of what's being added.  If it can stand on
> its own, $HOME/.vim/after/syntax/cpp.vim would likely be better so
> future updates to upstream's cpp.vim aren't lost.
>
>  
Possibly -- but consider that syntax files are dependent on statement
ordering for priority.  Consequently a line of syntax may work correctly
when placed properly in a syntax file but not work at all right when
placed at the end of the file, which essentially is what putting such
modifications into ...after/syntax is equivalent to doing.

Regards,
Chip Campbell

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