Skip to main content
Share Your Experience: Take the 2024 Developer Survey
16 votes
Accepted

Enable hl-line-mode globally

just add this to your .emacs or init.el file : (global-hl-line-mode 1).
Chakravarthy Raghunandan's user avatar
11 votes

Enable hl-line-mode globally

@Chakravarthy Raghunandan answered your question completely and succinctly. But you owe it to yourself to learn to ask Emacs -- that will help you much more, both immediately and in the long run. ...
Drew's user avatar
  • 77.9k
8 votes
Accepted

How do I highlight the current line?

Likely many ways to do this but the built in package called hl-line works very nicely. M-x hl-line-mode works as a local minor mode. or M-x global-hl-line-mode works as a global mode. goto https://...
SeJ's user avatar
  • 108
8 votes

Combine highlight-symbol-mode and hl-line-mode

highlight-symbol-mode uses text properties, not an overlay. hl-line-mode uses an overlay, not text properties. Overlays always take precedence over text properties, no matter how low the overlay ...
Drew's user avatar
  • 77.9k
8 votes

Highlight current line without changing colours

Just for reference, try (set-face-attribute 'hl-line nil :inherit nil :background "gray6")
Yadoo86's user avatar
  • 81
5 votes

Highlight current line without changing colours

This works for me, with this in my .emacs. See how the syntax colours are nicely preserved? (thx Yadoo86) ;; highlight line with the cursor, preserving the colours. (set-face-attribute 'hl-line nil :...
ohainaut's user avatar
5 votes

Highlight current line without changing colours

This is the case by default for me: hl-line-mode by default uses a face which only specifies a background color. That face is hl-line which by default just inherits from highlight. So maybe the ...
Stefan's user avatar
  • 26.5k
4 votes
Accepted

Automatically turn on hl-line-mode inside org-mode tables

Org mode does provide the org-at-table-p function that can be used to determine if the cursor is inside an org table. You would need to check this every time the cursor moves, which could be done ...
glucas's user avatar
  • 20.6k
3 votes
Accepted

Why is hl-line+.el not a package?

It was on MELPA. It's not on MELPA anymore because MELPA doesn't want to pull from Emacs Wiki anymore. It's on Emacs Wiki because that's where I prefer to upload it. And it is a "package" - a single ...
Drew's user avatar
  • 77.9k
3 votes

hl-line face used as default in 26.1

You are right that describe-face ultimately calls get-char-property (via face-at-point). get-char-property, unlike its cousin get-text-property, doesn't return just text properties, but also overlay ...
Oliver Scholz's user avatar
2 votes
Accepted

How to change setting for all modes except one?

Usually you customize a mode adding functions to the mode hook. To disable the hl-line-mode use the following code (add-hook 'org-mode-hook (lambda () (set (make-local-variable '...
matteol's user avatar
  • 2,018
2 votes

Highlight current line in GUD disassembler window

This is the solution I came up with using hl-line. I needed to advise the function that updates the disassembly buffer and invoke hl-line-highlight directly to make it work. (defadvice gdb-...
nispio's user avatar
  • 8,235
2 votes
Accepted

Incremental search line highlight

Three ways I can think of: Turn on hl-line-mode. This just always highlights the current line. Put the function you use to highlight the current line on isearch-update-post-hook. You can use this ...
Drew's user avatar
  • 77.9k
2 votes
Accepted

Highlight current line in org-agenda

(add-hook 'org-agenda-finalize-hook #'hl-line-mode)
gigiair's user avatar
  • 2,186
2 votes
Accepted

hl-line-mode interferes with custom syntax highlighting

I believe what you need to do is check the inheritance of the various faces. This can be done with describe-face. The available options are given in the manual under Face Attributes, but I believe ...
Lorem Ipsum's user avatar
  • 4,517
1 vote

Nonbreakable space font

I don't see that. What Emacs version are you using? Do you see that if you start Emacs with emacs -Q (no init file)? If not, then bisect your init file to find the culprit. If yes, then click the ...
Drew's user avatar
  • 77.9k
1 vote
Accepted

How to automatically enable a mode for only one specfic type of buffer?

That's what hooks are for: (add-hook 'dired-mode-hook 'hl-line-mode)
wasamasa's user avatar
  • 22.2k
1 vote

hl-line face used as default in 26.1

At the particular location of interest in the current buffer, type C-u C-x = and that will pull up a *Help* buffer that describes the various faces, text properties, overlays and additional ...
lawlist's user avatar
  • 19.2k
1 vote

Highlight current line in GUD disassembler window

Thanks to @lawlist nudging me into the source code, I found out that gdb mode will highlight the line for me, but only on the condition that the window containing the disassembly does not have fringes....
nispio's user avatar
  • 8,235
1 vote
Accepted

How can I eliminate the side effect of left margin?

It looks, to me, like it might be a bug. The hl-line-mode code moves its overlay (using move-overlay) to line-beginning-position, which is at the beginning of the buffer text for the current line (...
Drew's user avatar
  • 77.9k
1 vote
Accepted

How to account for tabs in `hl-line-range-function`?

How 'bout (defun my-hl-line-range-function () (cons ;; (point) ;; works nice too, cursor instead of indentation (save-excursion (back-to-indentation) (point)) (line-beginning-position 2)))...
Stefan's user avatar
  • 26.5k
1 vote
Accepted

Setting hl-line-mode for programming modes

There was an unrelated problem where a symbolic link was not set so the changes I made to the init file were not being loaded. Now it works.
Juan Herrero Diaz's user avatar
1 vote
Accepted

Eval-buffer works, init does not hl-line fix

The problem is coming from: (add-hook 'pre-command-hook #'my-hl-line-after-unhighlight nil t) (add-hook 'post-command-hook #'my-hl-line-after-current-line nil t) The nil t at the end means that you ...
Stefan's user avatar
  • 26.5k
1 vote

hl-line-mode hide background, how to avoid this?

Stumbled on this question when attempting not to make the hl-line override the background (although it was indentation guides in this case): I settled on this, which starts drawing the highlight line ...
ideasman42's user avatar
  • 8,826

Only top scored, non community-wiki answers of a minimum length are eligible