What i'm trying to do here is that, in my buffer I want to point the cursor position through highlighting the line horizontally and column vertically. Much like the CrosshairHighlighting mode.

enter image description here


(global-hl-line-mode 1)
(set-face-background 'highlight nil) 
(set-face-foreground 'highlight nil) 
(set-face-underline-p 'highlight "#ff0000") 

So using hl-line library pkg and these 4 line code in my .emacs, I got my desired part of highlighting the line in underline mode. Here is my emacs ss: enter image description here

(vline-global-mode 1)
(set-face-background 'vline "#ff0000")
(set-face-foreground 'vline nil)

Similarly I try to set-up for vertical-line with vline library pkg, but unable to thinner the block. Searched a lot about it but couldn't figure it out.


I tried this one earlier to set the vline-style variable to "compose" value (setq vline-style 'compose) it will show the vertical line as a pipe symbol | which is thicker line. But The problem is that the pipe doesn't look aesthetically pleasing because there is a small gap between lines.

  • Paging @lawlist
    – phils
    Sep 4, 2022 at 2:27
  • 1
    There is no typographical convention for drawing vertical lines next to text but there is a convention called “underlining” for drawing horizontal lines underneath text, so that’s what Emacs implements. Emacs also doesn’t really provide any vector–drawing primitives that draw to the gui window, though I imagine that you could add them without too much difficulty. Maybe try composing with the BOX DRAWINGS LIGHT VERTICAL (U+2502) “│” instead? It is intended not to have gaps, so perhaps your preferred font will manage to draw it that way.
    – db48x
    Sep 4, 2022 at 3:33
  • 1
    @phils -- thanks for the invitation to this thread. The main vline package and the packages written by Drew that make use of vline are about as good as it gets with a Lisp implementation. Some fonts permit composing characters to make use of the pipe; however, I never had much luck with my preferred fonts on OSX. [I wrote up an unfinished draft patch in C a few years ago that can create a one (1) pixel vertical and horizontal bar, with the vertical bar capable of slicing through a character at any "x" coordinate (e.g., when dealing with double-wide characters or variable pitch font).]
    – lawlist
    Sep 4, 2022 at 4:28
  • emacs.stackexchange.com/tags/elisp/info
    – Drew
    Sep 5, 2022 at 17:20
  • Please don't post the same question to emacs.SE and StackOverflow. Please choose one to keep and delete the other. Thx.
    – Drew
    Sep 5, 2022 at 17:33

1 Answer 1


EDIT add screenshot (suggested in the comments)

enter image description here


To get the full height, you can use the character M-x insert-char BOX DRAWINGS LIGHT HORIZONTAL.

However, it seems, that using the 'compose' vline-style, does not give pleasant results.

Therefore, it is better to set the character for the 'face' vline-style in the vline-show function directly. For that, replace the space after the ? on line 275 in the file 'vline.el' (just use M-x find-library or jump to the definition of vline-show directly) with the BOX DRAWINGS LIGHT HORIZONTAL character (as explained above), so that it looks as follows:

(line-char (if compose-p vline-line-char ?│))

and press C-M-x to evaluate the function.

Then set the vline-style to 'face', and then with M-x customize-face vline, remove the Background property, and set your preferred color for the Foreground property.

  • Perhaps you could add a screenshot of your solution :)
    – db48x
    Sep 5, 2022 at 17:55
  • Might be good idea. I have added a screenshot with the result I got for vline. I am not using 'crosshairs' nor the 'vline'. This is just an answer that I could quickly come up with... Sep 5, 2022 at 20:50
  • Not bad, though the weird brightening at the ends of the │ characters is weird. Does your font overlap them? Are you using transparent colors or is the antialiasing doing something funny? It would be so much nicer if we could just draw a line of pixels on the screen. :)
    – db48x
    Sep 6, 2022 at 8:26
  • I have no idea what is the reason for the 'brightenings'. Also, I don't know how to find the answers to your questions (about overlapping, transparency and anti-aliasing). I'm happy to have a look if you'll tell me how to check these things... Sep 6, 2022 at 8:56
  • Welcome to the rabbit hole!
    – db48x
    Sep 6, 2022 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.