[Home]Highlighting In Vim

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Difference (from prior major revision) (minor diff, author diff)

Changed: 3c3
g-code syntax hilighting for the vim editor
Syntax hilighting for vim

Changed: 7c7,21
The syntax file I made (links/install how-to near the end of this email) is understandably remedial, given the single night of R&D, but it already properly

Installation



#make yourself a ~/.vim/ directory
#make a syntax directory in there
#save upload:ngc.vim into ~/.vim/syntax/
#save upload:filetype.vim into ~/.vim/ (or merge with your existing one, if any):
#open, or restart vim
#open any files with *.ngc extensions, and it should auto-highlight them

You can also force highlighting with:
:set syntax=ngc

There are ways to have Vim check a few lines in the file to determine type, but that's more involved, and an exercise for a later date. You can duplicate the
au! line in filetype.vim to add your own extension(s), or just modify the one that's already there (*.ngc).

The syntax file I made is understandably remedial, given the single night of R&D, but it already properly

Changed: 10c24,25
types - all are linked to types that already exist in Vim. (as it should be.)
types - all are linked to types that already exist in Vim. I happen to have a lot of my subtypes as the same core type colors, so there's actually more separation of highlight types than you're seeing, but already I
think it's a bit easier to visually parse.

Changed: 23,24c38,39
* all g-codes�
* all m-codes�
* all g-codes
* all m-codes

Changed: 34c49
* everything is case-insensitive, as w/ RS274 NGC gcode (g1, and G1 are the same)
* everything is case-insensitive, as w/ NGC/LinuxCNC (g1, and G1 are the same)

Removed: 62,78d76

Installation



#make yourself a ~/.vim/ directory
# make a syntax directory in there
#save [ngc.vim] into ~/.vim/syntax/
#save [filetype.vim] into ~/.vim/ (or merge with your existing one, if any):
#open, or restart vim
#open any files with *.ngc extensions, and it should auto-highlight them

You can also force highlighting with:

:set syntax=ngc

There are ways to have Vim check a few lines in the file to determine type, but that's more involved, and an exercise for a later date. You can duplicate the
au! line in filetype.vim to add your own extension(s), or just modify the one that's already there (*.ngc).

I happen to have a lot of my subtypes as the same core type colors, so there's actually more separation of highlight types than you're seeing, but already I
think it's a bit easier to visually parse.

Changed: 81c79
wiki powers, but if someone would like to add it, that would also be nice. Thanks! you're welcome, btw
wiki powers, but if someone would like to add it, that would also be nice. Thanks! you're welcome. btw, how to edit wiki pages.

upload:synton.png

Syntax hilighting for vim

from [this email thread]

Installation

  1. make yourself a ~/.vim/ directory
  2. make a syntax directory in there
  3. save upload:ngc.vim into ~/.vim/syntax/
  4. save upload:filetype.vim into ~/.vim/ (or merge with your existing one, if any):
  5. open, or restart vim
  6. open any files with *.ngc extensions, and it should auto-highlight them

You can also force highlighting with:

  :set syntax=ngc

There are ways to have Vim check a few lines in the file to determine type, but that's more involved, and an exercise for a later date. You can duplicate the au! line in filetype.vim to add your own extension(s), or just modify the one that's already there (*.ngc).

The syntax file I made is understandably remedial, given the single night of R&D, but it already properly highlights a rather extensive set of the files I tested. I endeavored to break up each highlighting type in sensible, pre-defined ways, such that the power user with lots of the standard sub-types defined for their Vim sessions could benefit from something passably familiar. In fact, there are no custom highlight types - all are linked to types that already exist in Vim. I happen to have a lot of my subtypes as the same core type colors, so there's actually more separation of highlight types than you're seeing, but already I think it's a bit easier to visually parse.

Feature Summary

Here's what I got to highlight before giving up:

Cool extras:

Caveats:

There could be all manner of fancy extras, like catching lots of other errors, and flagging them as such, but it gets rather complicated rather quickly. I wanted to post this ASAP in case it helps any Vim users, and in case anyone wanted to enhance it with things like more robust error-checking, tighter adherence to the spec, or new ways to break up the concepts (e.g. highlighting an entire X[#<something>] block as a single type (not my preference, but perhaps someone would prefer that), or properly checking item locations in lines, or getting negative constants working, without breaking all else. There are a lot of parts of the g-code spec that I've never touched (e.g. I've never used an M-code), so I've probably missed whole swaths of highlightables.

Anyway, feedback/corrections much appreciated, and if anyone gets it working, or makes some nice modifications, I'd love to hear about it. I don't think I have wiki powers, but if someone would like to add it, that would also be nice. Thanks! you're welcome. btw, how to edit wiki pages.

-Gary Fixler


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited January 21, 2012 6:58 am by CNCDreamer (diff)
Search:
Published under a Creative Commons License