is there any way to get a separator like the one for the split buffers (line in the middle of the image) for the line numbers/fringe?

I tried (setq linenum-format "%4d \u2502 ") but that gives me a buggy weird broken lines with varying widths -.-

broken separator lines


There are a few ways to do this -- my preferred method is to set the frame defaults for the fringes:

(set-face-attribute 'fringe nil :background "red")
(add-to-list 'default-frame-alist '(left-fringe . 11))
(add-to-list 'default-frame-alist '(right-fringe . 0))

It is possible to set the windows fringes globally:

(setq-default left-fringe-width 11)
(setq-default right-fringe-width 0)

It is also possible to set the windows fringes locally:

(setq left-fringe-width 11)
(setq right-fringe-width 0)

Here is the doc-string for left-fringe-width and right-fringe-width:

Automatically becomes buffer-local when set.

Width of this buffer's left/right fringe (in pixels).
A value of 0 means no left/right fringe is shown in this buffer's window.
A value of nil means to use the left/right fringe width from the window's frame.

Setting this variable does not take effect until a new buffer is displayed
in a window.  To make the change take effect, call `set-window-buffer'.


  • Correct me if I'm wrong but that only changes the fringe's background color and does not add a separator line between fringe and buffer.
    – nemesit
    Dec 13 '14 at 14:44
  • The proposed code offers a way to control the thickness and color of the fringe, or the fringe can be eliminated entirely. The screenshot contains an unrelated vertical line for a custom cross-hair mode that I use; however, that is beyond the scope of the fringe modification example in this answer. Here is a link to a related question where the comments indicate an extra vertical line is not easily accomplished: stackoverflow.com/q/25760235/2112489
    – lawlist
    Dec 13 '14 at 22:41
  • Yeah changing the fringe thickness is not exactly what I was looking for because i'd like to keep both fringe and line numbers. It's weird that emacs can easily display a line between buffers but adding one to separate line numbers and the fringe seems to be an impossible task.
    – nemesit
    Dec 14 '14 at 11:22

I too want a way to differentiate between the line number column and code. This is how I do that.

(set-face-attribute 'line-number nil :background "gray96" :foreground "gray42")
(set-face-attribute 'line-number-current-line nil :foreground "gray6")

Here is a screenshot of this... ...with the leuven-theme in spacemacs

You have other options that you can find in the faces.el file.

It doesn't answer the question, but solves the underlying problem for me. This is also how vim often does it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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