unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* highlight all lines with a certain prefix
@ 2009-07-06  6:13 n179911
  2009-07-07  6:54 ` tomas
  2009-07-07 13:37 ` Thien-Thi Nguyen
  0 siblings, 2 replies; 5+ messages in thread
From: n179911 @ 2009-07-06  6:13 UTC (permalink / raw)
  To: help-gnu-emacs

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?

Thank you.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: highlight all lines with a certain prefix
       [not found] <mailman.1966.1246938928.2239.help-gnu-emacs@gnu.org>
@ 2009-07-07  6:17 ` Stefan Kamphausen
  2009-07-07 10:53 ` Alan Mackenzie
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Kamphausen @ 2009-07-07  6:17 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

n179911 <n179911@gmail.com> writes:

> 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?

first consider the regexp: ^[ ]*-
That is the beginning of a line (^) followed by a space (here rather
inelegantly represented as a group, [ ]) zero or more times (*),
followed by a dash (-).

Personally I'd use this regexp in occur which pops up a new buffer which
I can use to get an overview and to navigate to the matching lines:
M-x occur ABOVE_REGEXP RET

In your case it sounds more like highlight-lines-matching-regexp:
M-x highlight-lines-matching-regexp ABOVE_REGEXP RET RET

BTW:  Just typing M-x highlight-TAB would have given you a hint.


Cheers,
Stefan
-- 
Stefan Kamphausen --- http://www.skamphausen.de
a blessed +42 regexp of confusion (weapon in hand)
You hit. The format string crumbles and turns to dust.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: highlight all lines with a certain prefix
  2009-07-06  6:13 highlight all lines with a certain prefix n179911
@ 2009-07-07  6:54 ` tomas
  2009-07-07 13:37 ` Thien-Thi Nguyen
  1 sibling, 0 replies; 5+ messages in thread
From: tomas @ 2009-07-07  6:54 UTC (permalink / raw)
  To: n179911; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Jul 05, 2009 at 11:13:04PM -0700, n179911 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?

 1) Incremental search might be what you want. Hit C-s (Control key plus
    's'), type the string you are looking for. All matches within the
    window are highlighted while you type. If you hit C-s again, the
    current position is advanced to the next hit.

 2) If you want to see as many hits as possible, type M-x occur (Meta-x,
    where Meta is typically the Alt key, sometimes the ESC key), then
    the word 'occur' in the minibuffer, then <enter>. You are prompted
    for a regular expression, All hits are showed in a new window. Each
    hit is a link to the position in the original buffer.

As a variation to (1) there is "incremental regular expression search"
(look for "isearch-forward-regexp" and "isearch-backward-regexp" in the
docs).

HTH
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFKUvEqBcgs9XrR2kYRArq0AJsGxCnKgAt3n+GbPJoyVhgq/uJBgACdFOrE
UPmKpiWZx+iaEaejJYb62dE=
=4Rhm
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: highlight all lines with a certain prefix
       [not found] <mailman.1966.1246938928.2239.help-gnu-emacs@gnu.org>
  2009-07-07  6:17 ` Stefan Kamphausen
@ 2009-07-07 10:53 ` Alan Mackenzie
  1 sibling, 0 replies; 5+ messages in thread
From: Alan Mackenzie @ 2009-07-07 10:53 UTC (permalink / raw)
  To: help-gnu-emacs

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).



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: highlight all lines with a certain prefix
  2009-07-06  6:13 highlight all lines with a certain prefix n179911
  2009-07-07  6:54 ` tomas
@ 2009-07-07 13:37 ` Thien-Thi Nguyen
  1 sibling, 0 replies; 5+ messages in thread
From: Thien-Thi Nguyen @ 2009-07-07 13:37 UTC (permalink / raw)
  To: help-gnu-emacs

() n179911 <n179911@gmail.com>
() Sun, 5 Jul 2009 23:13:04 -0700

   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?

One way is to use Outline mode, tweaked appropriately.  For
example, see <http://www.gnuvola.org/software/guile-pg/NEWS>
(look at the end of the file for the "Local Variables" block).

thi




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-07 13:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-06  6:13 highlight all lines with a certain prefix n179911
2009-07-07  6:54 ` tomas
2009-07-07 13:37 ` Thien-Thi Nguyen
     [not found] <mailman.1966.1246938928.2239.help-gnu-emacs@gnu.org>
2009-07-07  6:17 ` Stefan Kamphausen
2009-07-07 10:53 ` Alan Mackenzie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).