help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: highlight all lines with a certain prefix


From: Alan Mackenzie
Subject: Re: highlight all lines with a certain prefix
Date: Tue, 7 Jul 2009 10:53:39 +0000 (UTC)
User-agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (FreeBSD/4.11-RELEASE (i386))

n179911 <n179911@gmail.com> wrote:
> Hi,

> In emacs, is there a way which highlight lines with certain prefix in
> a file?  For example I want to highlight all lines with '-' or '     -'
> (a lot of spaces followed by a '-' of a file?

Yes, indeed!  It's Emacs after all.

Do M-x hi-lock-mode.  This switches on the requisite minor mode.

Then do C-x w l, and type in a regular expression.  I would suggest this
one:

    ^ *-

, or if you want to catch lines with tab characters too, then

    ^[ ^Q<TAB>]*-

, where "^Q<TAB>" means type C-q follwed by the <TAB> key.  Choose a face
(e.g. hi-yellow) from the minibuffer prompt, and you've got what you
want.

If you're not familiar with regular expressions, learn them!  The effort
will pay off massively and quickly.  Have a look at the page "Regular
Expressions" in the elisp manual.

> Thank you.

Have fun!

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]