38

For Emacs version >= 26 you should use display-line-numbers-mode or global-display-line-numbers-mode. As @eric-brown mentioned you can use M-x linum-mode. Another good idea is to use (add-hook 'prog-mode-hook 'linum-mode) in your init.el to automatically enable linum-mode in all programming modes. See EmacsWiki


14

M-x linum-mode will do the trick. If you wish to effect this for all buffers, then M-x global-linum-mode will do this.


12

M-x find-library will let you select a library and take you to the source code. Note that you may not have the elisp files installed on your machine. For Ubuntu, try installing emacs24-el (or whatever version you're on; look for the ...-el to get the elisp source).


12

If you are using Emacs 26 or newer, you can use display-line-numbers-mode. from etc/NEWS.26: ** Emacs now supports optional display of line numbers in the buffer. This is similar to what 'linum-mode' provides, but much faster and doesn't usurp the display margin for the line numbers. Customize the buffer-local variable 'display-line-numbers' to ...


12

Like most terminals, Emacs' term has a scrollback limit -- which will naturally mess with the consistency of linum's counting, as lines will be deleted from the beginning of the buffer. The term-buffer-maximum-size variable controls this, and sure enough it has a default value of 2048. So linum was telling you the truth: the terminal buffer was never more ...


6

Enable Linum Mode for all files [...] but not other buffers? How about: (add-hook 'find-file-hook 'linum-mode)


6

The Problem The problem here is that there’s no face to control the appearance of the margins. You can display text in the margin using overlays (that’s what linum-mode does) but, like any text in Emacs, it’s constrained to the limits of the buffer. So you can’t have any control over the margin display beyond the last line of the buffer. What you can do, ...


6

Linum mode provides the linum-format customizable variable that allows you to format how you want your line numbers to appear. Set this variable to have the value "%x" to get hexadecimal line numbers. This can be done either through the built-in customization process or by running (setq linum-format "%x"). Edit: You may only want to have ...


5

Because the last line hasn't started yet. Adding newline symbol to the end makes the cursor jump from the current line to the next one, but it doesn't add anything to it (new one). Strictly speaking, it is not a line yet. Supposing that every newline symbol was visible, you would get 1. <newline_symbol> 2. <newline_symbol> 3. <...


5

nlinum-mode is another option. It has the same interface as linum-mode, so you can use the same hooks, but it uses a different technology to be more performant. Quote from nlinum.el: ;; This is like linum-mode, but uses jit-lock to be (hopefully) more efficient. You can install it via GNU Elpa via the usual list-packages. http://elpa.gnu.org/packages/...


5

If you are looking for source of a function <name>, you can find a link to the source in the description of the function: C-h f <name> RET In your case it will be: C-h f linum-mode RET Starting from Emacs 24.3 C-h f can perform autoloading: When this command is called for an autoloaded function whose docstring contains a key substitution ...


5

(setq visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow))


5

The intention behind nlinum.el was to obsolete linum.el but it turns out that some customizations of linum.el can't really be adapted to nlinum.el (mostly the "relative line numbers"). Also the new display-line-numbers-mode in Emacs-26 aims to obsolete both of those. But again, some customizations of nlinum.el and linum.el can't be adapted to display-line-...


4

Here are two basic options to run a function (in this case, linum-relative-toggle) at start-up. Simple option: add (linum-relative-toggle) to your init file (probably at the end). Somewhat more involved option (may be necessary if the simple option doesn't help for some reason): use (add-hook 'after-init-hook #'linum-relative-toggle). after-init-hook's ...


4

A solution covering nearly every file would be making use of the fact that nearly all buffers for these are derived from text-mode and prog-mode: (add-hook 'text-mode-hook 'linum-mode) (add-hook 'prog-mode-hook 'linum-mode)


3

linum-mode was added in Emacs 23.1. See the related NEWS file, or if you have 23.1+ version of Emacs, you can find this information via C-u C-h n 23.1 then C-s linum. I know it's 23.1 because I searched linum across all NEWS files.


3

At the top of the buffer: # -*- eval: (linum-mode 1) -*- https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html


3

Certainly linum-mode is a good choice. If you don't always want to see line numbers, like me, you can use this trick from the excellent What the .emacs.d!? blog. This temporarily enables linum-mode when you run goto-line. Here's the code from his blog: (global-set-key [remap goto-line] 'goto-line-with-feedback) (defun goto-line-with-feedback () "Show ...


3

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


3

Line numbers (of the kind that's displayed as a strip with every line number on a window's side) are known for their performance and redrawing issues. One of them is that they're using the display margin which interferes with other packages that (indirectly) manipulate the margins. The more prominent examples would be auto-complete-mode and company-mode. ...


3

The built-in line numbering mechanism uses the text-area that is sandwiched between the left/right fringes and/or left/right margins, to the extent that fringes/margins exist. [What happens internally is that the line number glyphs (with a space on each end) are prepended to the glyphs of the display line within the text area.] Thus, setting the fringe or ...


2

I would highly recommend against editing linum.el. The huge disadvantage of doing that is that your changes will be lost every time the package gets updated. Also, that page you linked said you can achieve the same effect without editing linum.el by doing this: (setq linum-format “%d “)


2

You could put this in dotspacemacs/config: (global-linum-mode) (with-eval-after-load 'linum (linum-relative-toggle)) The relative number line will be by default.


2

The linum-off.el file by Matthew Fidler should be what you are looking for. Here is a copy of his code: (require 'linum) (defcustom linum-disabled-modes-list '(eshell-mode wl-summary-mode compilation-mode org-mode text-mode dired-mode doc-view-mode image-mode) "* List of modes disabled when global linum mode is on" :type '(repeat (sexp :tag "Major ...


2

This is what I put in my init.el file to fix the problem. It's a hack, at some sizes the left margin is a bit off but so far this is the best solution I've found to this problem. (defun adjust-left-margin-hook () (let ((new-margin (+ 1 text-scale-mode-amount))) (setq left-margin-width (if (< new-margin 0) 0 new-margin)) (set-window-buffer nil (...


2

Here you go: (global-set-key [remap goto-line] #'my-goto-line) (defvar my-temp-linum-mode-sym (if (fboundp 'display-line-numbers-mode) 'display-line-numbers-mode 'linum-mode) "Use `display-line-numbers-mode' if it's available; `linum-mode' otherwise.") (defun my-goto-line (line &optional buffer) "`goto-line' with temporary line-...


2

You could customize the variable linum-format to be a format string that begins with a space. The simplest would be (setq linum-format " %d") which sticks one space in front of the formatted digit. I tried it out and it looks slightly weird: The other thing is that if you're on Emacs 26, there is a new line number mode display-line-numbers-mode which is "...


1

The following links linum wiki and stackoverflow similar issue help me to reach a solution with the following code : (require 'linum) (add-hook 'prog-mode-hook 'linum-mode) (defvar my-linum-format-string "%3d") (add-hook 'linum-before-numbering-hook 'my-linum-get-format-string) (defun my-linum-get-format-string () (let* ((width (1+ (length (number-to-...


1

package nlinum has option nlinum-format. You can set option to value like this: (setq nlinum-format "%d "). Just like package linum can be configured like this: (setq linum-format "%4d \u2502").


1

What I wanted is achieved by (setq display-line-numbers-type 'visual) (global-display-line-numbers-mode) And all this time I've been stuck with avy in org mode.


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