0

FINAL EDIT: I have "manually migrated" this question to the new Vi(m) SE site: https://vi.stackexchange.com/q/2219/1060


My Vim syntax highlighter for ft=cpp is prematurely ending some macros mid-line. For example:

highlighting error example

(The italicization may make this example a little hard to understand; the final character in the second line is \.)

This is part of a multi-line macro; note that the transition from blue (the "macro" style) to grey and italicized (the "comment" style) occurs mid-word (it's on the 12th line of the macro, but I've seen other cases where it happens on a different line).

Does anyone have any ideas what's going on here? I tried googling to see if this was a known issue, but I didn't see anyone stating that they had this particular problem.

I'm using vim-gtk (Vim 7.4) from the Wheezy-Backports repo.


Edit: It appears that the macro highlighting style ends as soon as the first 0 is encountered anywhere other than at the start of a token. For instance, the number 0 itself does not end the macro, nor does the word 0DIAGNOSTIC, but DIAGNOSTIC0 does (regardless of what follows the 0).


Edit 2: Since the problem is reproducible even with -N -u NONE (see comments on Ingo Karkat's answer), here's the complete output of vim --version, just in case it's helpful:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 14 2014 15:36:29)
Included patches: 1-488
Modified by [email protected]
Compiled by buildd@
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
+balloon_eval    +float           +mouse_urxvt     -tag_any_white
+browse          +folding         +mouse_xterm     +tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      +toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    +xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12     -g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/usr/include/tcl8.5  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_LARGEFILE64_SOURCE=1  
Linking: gcc   -L. -Wl,-z,relro -rdynamic -Wl,-export-dynamic -Wl,-E  -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl/5.14/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions  -L/usr/lib -ltcl8.5 -ldl -lpthread -lieee -lm -lruby-1.9.1 -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib   

Edit 3: I'm using the SyntaxAttr plugin to get information about the last macro-highlighted character and the first comment-highlighted character.

Last macro character: group: cDefine->PreProc guifg=5(5) guibg=-1(-1) First non-macro character: cCppOut2->Comment guifg=6(6) guibg=-1(-1)


Edit 4: The output of :scriptnames:

1: /usr/share/vim/vim74/menu.vim
2: /usr/share/vim/vim74/autoload/paste.vim
3: /usr/share/vim/vim74/syntax/syntax.vim
4: /usr/share/vim/vim74/syntax/synload.vim
5: /usr/share/vim/vim74/syntax/syncolor.vim
6: /usr/share/vim/vim74/filetype.vim
7: /usr/share/vim/vim74/syntax/cpp.vim
8: /usr/share/vim/vim74/syntax/c.vim
2
  • Please include a full example macro that shows the problem. Feb 10, 2015 at 12:10
  • @IngoKarkat I've replaced the original image. The characterization I gave in my edit appears to be pretty comprehensive/accurate. Feb 10, 2015 at 17:16

1 Answer 1

1

I cannot reproduce the problem, not with the latest 7.4.608, nor with 7.4, or 7.0. I think you have custom syntax extensions that cause this.

Try with $ vim -N -u NONE; the problem probably is gone then.

You should then check your syntax extensions (~/.vim/after/syntax/cpp.vim, ~/.vim/syntax/cpp/*.vim, etc.). You need to find out which syntax group causes the highlighting. :syn list shows all active groups, but it's easier when you install the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin. When you have the name of the offending syntax group, you can investigate where it comes from; (the last lines of) :scriptnames may help.

5
  • Nope, the problem persists even with -N -u NONE, much to my surprise. I've added the output of vim --version to the original question, just in case something there might be a tip-off. Feb 12, 2015 at 17:17
  • I'll try the SyntaxAttr plugin and let you know what I see. Feb 12, 2015 at 17:22
  • I've now added info from the SyntaxAttr plugin. Feb 12, 2015 at 17:32
  • Thanks for making these valuable checks; I'm stumped as to why this happens with plain vanilla Vim. You could double-check with :scriptnames that really no file outside of Vim's runtime is being loaded. Feb 13, 2015 at 7:47
  • I've decided to "manually migrate" this question to the new Vi/Vim SE site. Please feel free to migrate your answer as well. vi.stackexchange.com/q/2219/1060 Feb 25, 2015 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .