Gedit Syntax Highlighting for Assembler Files (*.Asm)

gedit syntax highlighting for assembler files (*.asm)

The following steps should be enough.

wget http://www.carminebenedetto.net/_downloads/asm-intel.lang
sudo cp asm-intel.lang /usr/share/gtksourceview-3.0/language-specs/

Note that the exact folder to copy the .lang file to depends upon your version. You may have gtksourceview-2.0 instead, or even something else. On my machine I had both 2.0 and 3.0, and copied the file into each one's language-specs subfolder.

Gedit syntax highlighting not working

Finally figured out my issue after a lot of messing around with it. I was working with programs that involved editing my LD_LIBRARY_PATH environment variable, so I added a couple lines into my .cshrc to add append a few shared libraries. I made to sure to append my newly added libraries to the variable but for whatever reason this still messed up Gedit's ability to do syntax highlighting. After taking the setenv commands out of my .cshrc script, I rebooted and Gedit's syntax highlighting was back to normal.

I've heard using LD_LIBRARY_PATH was considered bad practice. Now I have first-hand experience on what can go wrong.

syntax highlighting for Assembler

If you have a limited set of identifiers, and if they all consist solely of keyword characters, then :syn keyword is the best choice. You're right in that :syn match provides a superset of functionality. Essentially,

:syn keyword myGroup foobar

is equivalent to

:syn match myGroup "\<foobar\>"

Beware of old versions

The syntax/asmh8300.vim syntax you've referenced is from 2002, it may not be the best example of how to write a syntax file. (For example, it omits the \<...\> around its matches, what looks like a bug to me. And it still has compatibility stuff for Vim 5 / 6 that's not needed any more.)

Also, do you actually use Vim 7.0?! Vim 7.0 is from 2007 and very outdated. It should be possible to install the latest version 7.3; if you can't find a proper package for your distribution (for Windows, check the binaries from the Cream project, it's also not very difficult to compile (e.g. from the Mercurial sources) on Linux.

Borrow other syntax elements

If other syntaxes are embedded in your syntax, and clearly delimited (e.g. like JavaScript inside HTML), you can :syn include it. But if there are just similar constructs, it's best to copy-and-paste them into your syntax (and adapt at least the group names). You need to be careful to catch all contained syntax groups, too; together with syntax clusters, the hierarchy can be quite complex!

More tips

When writing a syntax, you often 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.



Related Topics



Leave a reply



Submit