Ads by Google

Showing posts with label highlighting. Show all posts
Showing posts with label highlighting. Show all posts

Monday, May 19, 2008

If ediff highlighting is confusing you....

then there is a simple configuration tweak to fix that. ediff highlights all the differences in a riot of colours and it takes some time to focus on the chunk that is highlighted or active.
A simple tweak that I found when browsing the emacs newsgroup. The settings makes only the current chunk highlighted thus making it simple to see the differences. Another minor change that can be set is the whitespace difference checking. I don't use it as I sometimes deal with data files and I need to see the spaces but otherwise it too is a simple fix when you're just interested in what's changed.



;; only hilight current diff:
(setq-default ediff-highlight-all-diffs 'nil)

;; turn off whitespace checking:
(setq ediff-diff-options "-w")



To know more about ediff, read the documentation here.

Wednesday, October 24, 2007

Pretty printing text using Emacs

Most editors will give you syntax colouring for languages which they support, typically Java, C++, and C and a gaggle of scripting languages. And a whole bunch of user supplied syntax files in each editor specific language file.


Emacs too provides such a feature but with a different twist where the things can be coloured on the fly. More importantly, any random buffer can be made to highlight any keyword based on regular expressions.

While working on Autosys scripts which had close to 100 odd steps it looked like the first screenshot.

To make it more readable, here's what I did

1. Colour the comment green
2. Colour the command shell script blue
3. Colour the Box name blue
4. Colour the condition as red

a. Start off by invoking M-x hi-lock-mode
b. hit C-x w l /\* RET hi-green-b and you get the second screenshot


c. hit C-x w l command: RET hi-blue-b
d. hit C-x w l box_name: RET hi-blue-b
e. hit C-x w l condition: RET hi-red-b

After doing the above, you should get something akin to the final screenshot. Now, that is something which is easier on the eyes (OK, bad colour choices) than the plain vanilla text file. In fact, nothing happens to the actual text file, only the emacs buffer containing the file is fontified.
In the Info manual, please see Emacs->Highlight Interactively to see other keybindings and colouring or font locking options.