Den lördagen den 25:e januari 2014 kl. 22:37:22 UTC+1 skrev Niklas Lindström: > Hi Peter, > > > > On Sat, Jan 25, 2014 at 5:13 AM, Peter Nguyen <[email protected]> wrote: > > > Hi, > > > > I have a twig (PHP HTML template) file with several non ascii characters at > different places. I can do a search with: > > > > /[\x7f-\xff]/ > > > > and it will match them. But when I try to add these commands to my .vimrc > file for highlighting them, it does not work: > > > > " Find non ASCII chars and highlight them > > syn match nonascii "[\x7f-\xff]" > > hi nonascii guibg=Red ctermbg=2 > > > > Anyone who knows what I'm doing wrong? > > > > Declaring syntax rules in the .vimrc will not work, since the syntax will be > cleared during vim startup (or something to that effect). > > > > > For your case, you can either add something like this to your .vimrc: > > > match ErrorMsg "[\x7f-\xff]" > > > > Or add your original commands to a file called ~/.vim/after/syntax/php.vim in > your home directory (create it and any needed parent directories if they > don't already exist). The "after" folder is a nice way to customize things > locally according to your needs. That file specifically will extend the php > syntax for you. > > > > See also e.g. <http://vim.wikia.com/wiki/Highlight_unwanted_spaces>. > > H.T.H. > Cheers, > Niklas > > > > > > -- > > -- > > You received this message from the "vim_mac" 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 > > > > --- > > You received this message because you are subscribed to the Google Groups > "vim_mac" group. > > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > > For more options, visit https://groups.google.com/groups/opt_out.
Hi Niklas, thanks for your answer. The match ErrorMsg "[\x7f-\xff]" works but only on the current file (.vimrc) after I source it. If I check the other file (twig) it didn't highlight the non-ascii characters. I haven't tried your suggestion with the "after" folder yet because I would want that non-ascii characters to be highlighted in all files, not just for php syntax. Is it possible? -- -- You received this message from the "vim_mac" 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 --- You received this message because you are subscribed to the Google Groups "vim_mac" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
