Questions tagged [line-numbers]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
35 views

Disable line number mode for compilation mode

I have set multiple modes to not show display-line-number-mode and recently I added compilation-mode to that list, but the compilation-mode still shows line numbers. Here is the relevant code, ;; ...
user avatar
0 votes
0 answers
27 views

How to separate line numbers from text when using global-display-line-numbers-mode?

Trying global-display-line-numbers-mode, I would like to achieve what linum-format does with: Linum: Separating line numbers from text How to achieve that using global-display-line-numbers-mode?
user avatar
  • 2,049
0 votes
1 answer
20 views

How can I have `menu-bar--display-line-numbers-mode-relative` run in all modes?

I see there is a menu-bar--display-line-numbers-mode-relative function that turns on relative line numbering. Is there a way I can run this in every buffer (basically turn this on everywhere)?
user avatar
  • 902
1 vote
1 answer
42 views

How to get the width of the window without line numbers? (or other content in the fringe)?

The result of window-body-width doesn't change when display-line-number-mode is enabled / disabled. How can I get the window width but excluding the fringe?
user avatar
  • 7,179
4 votes
0 answers
37 views

Is there a way to display the number of lines in a fold?

I have tons of nested headings in Org-mode files, usually collapsed, and I'd like to have a quick look at how many lines are under each of collapsed headings (mostly top-level but sometimes not). ...
user avatar
  • 352
1 vote
1 answer
47 views

How to prevent the moving of line numbers in display-line-numbers-mode

Sorry about the title, I don't know how to describe it better. Using display-line-numbers-mode with hs-hide-all to edit a Common Lisp file, I see the line number moving to the right, which is quite ...
user avatar
0 votes
1 answer
68 views

show line number when matching parathenses/braces

I work with latex/other documents with long nested of texts/codes are enclosed by paratheses or braces, like this: { long blocks of latex or other materials ( another long blocks of texts ...
user avatar
  • 101
0 votes
1 answer
168 views

Org mode: Enable line numbers only in source code blocks

Is there a way to enable line numbers only for the source code blocks between #+BEGIN_SRC and #+END_SRC?
user avatar
  • 111
1 vote
0 answers
16 views

Indicate line number thresold

How can I have a ruler displayed on a specific linenumber e.g. 20? Similar to M-x ruler-mode though for lines/rows instead of columns
user avatar
  • 617
1 vote
1 answer
50 views

How to fix buffer-local variable?

I have the following in my init.el, (setq-default display-line-numbers 'visual) (global-display-line-numbers-mode 1) which should give me relative line numbering. On starting emacs, it does on the ...
user avatar
  • 13
1 vote
1 answer
66 views

How to check if point moved or is on a different line in a buffer since the last user command?

I would like to make a snippet of code that only executes if the point is on a different line in a particular buffer since the last user command. The only way I could think to do it was using the post-...
user avatar
  • 163
0 votes
1 answer
49 views

How to let line numbers count from 1 in org subtree?

When I narrow an org mode header into a subtree(using command org-narrow-to-subtree) in vanilla Emacs, the line number counts from 1 in the subtree, but when I create a subtree in Doom Emacs, the line ...
user avatar
  • 439
0 votes
1 answer
133 views

Toggle between relative and absolute line numbers: Lisp Syntax

I need to define a function that toggles between value of display-line-numbers but can't figure out what's the correct lisp syntax to do so. Here's what I want to do: Check if value of display-line-...
user avatar
0 votes
0 answers
38 views

How can I add some line numbers of emacs into pdf created by latex

Is it possible to print Line Number in emacs to the Latex pdf for lines that I prefer? If it is easy, I want to use those numbers with M-g M-g (goto-line command) Edit: To make the question more clear,...
user avatar
  • 101
0 votes
1 answer
156 views

How to get the real line number of a selection?

I am trying to figure out the line numbers referring to the actual selection. What I came up with is something like this (let ((start (line-number-at-pos (region-beginning))) (end (line-number-...
user avatar
2 votes
1 answer
160 views

Number of line as you'd get moving down the buffer with C-n

In a buffer in Emacs, a line is the text you get from the first character after you press "Enter" to the last character before the next "Enter". And so, this is the line numbers ...
user avatar
0 votes
0 answers
202 views

How can I disable line numbers on empty lines?

I find it easier to visualize double line breaks if there's actually blank space between paragraphs. I never need to see the line number of a blank line, but I do really like seeing a line number when ...
user avatar
0 votes
1 answer
62 views

How to ignore emtpy lines on the bottom of the buffer?

When I jump to bottom part of the buffer using vi I does not show any empty lines. On emacs when I got to bottom of the buffer I see empty lines even there is no new lines exist. Is is possible to ...
user avatar
  • 1,076
1 vote
2 answers
66 views

Strange behaivor counting lines in hooks `find-file-hook` or `text-mode-hook`

For me, the clearest measure for the size of a file is its number of lines. So, I want this information in my mode line. I am using Doom emacs and, even I could define my own mode line, for such a ...
user avatar
  • 81
1 vote
1 answer
460 views

Emacs + visual line numbers + folding + visual fill column mode

Relative line numbers for me it's a little bit painful topic. I'm using evil (spacemacs) and I want to jump between lines by in vim style like 10j, 4k etc. Is it possible to get line numbers behavior ...
user avatar
2 votes
1 answer
550 views

Change line number format with line-number-mode

With linum-mode, you could change how the line numbers appears by customizing linum-format. line-number-mode appears to have replaced linum-mode, and indeed it is better (for one thing, it correctly ...
user avatar
  • 1,482
2 votes
1 answer
417 views

Uneven line numbers with display-line-numbers

Emacs for some reason did not vacate equal spaces for each line number, So the lines were starting at different places which made it harder to keep track of alignment. It wasn't just the relative mode ...
user avatar
7 votes
1 answer
3k views

How to change line-number gutter width using display-line-numbers mode?

I am using (global-display-line-numbers-mode 1) in my init.el file and everything is working as expected. The only problem is that I find the gutter width to be too wide and would prefer it to match ...
user avatar
  • 303
1 vote
1 answer
125 views

Add paragraph numbers

I have a longish document and I want to number the paragraphs. So, Here is the first paragraph. It could span multiple visual lines. Two paragraphs are separated by an empty line. converts to : 1 ...
user avatar
  • 1,668
4 votes
1 answer
539 views

Setting relative line numbers when in programming modes

Looking to set relative line numbers when in programming modes. Looking through the older posts I see a way to set line numbers based on the mode - How do I display line numbers in emacs (not in the ...
user avatar
  • 43
1 vote
0 answers
97 views

Huge buggy padding in line-number buffer

A picture: As you can see there is a huge waste of space on the left side of the line number section. When I increase the font size the padding even increases and does not decrease when I decrease ...
user avatar
  • 167
0 votes
1 answer
112 views

auto-start of linum mode doesn't work

I'm currently using spacemacs. I have put the line (global-linum-mode t) into the .spacemacs file but it doesn't work at all. It used to work when I used the normal emacs. I don't have any clue of ...
user avatar
4 votes
0 answers
177 views

Are zero-based column numbers an Emacs idiosyncrasy?

The first line of a text file is line number 1 in probably every application I have ever come across, including Emacs. Every application I have at hand also uses column number 1 for the first column ...
user avatar
  • 357
2 votes
3 answers
384 views

How to display absolute line numbers of a full, widened buffer when narrowing to just part of it?

This question applies in the context of all line numbering implementations I've tried, including line-number, nlinum, and linum, so I have a feeling that the answer will have something to do with ...
user avatar
  • 342
0 votes
1 answer
232 views

Line numbers break scroll margin

I'm trying to set a scroll margin to emacs with the scroll-margin variable, but I've noticed that when you do that and you have display-line-numbers-mode enabled, the scrolling doesn't work properly ...
user avatar
  • 1,914
1 vote
2 answers
533 views

Elisp program to insert line numbers into a buffer?

I am NOT looking for emacs's line-number mode. I don't want to just display line numbers. I want to insert line numbers in a buffer, starting at point and going to mark, or perhaps continuing for some ...
user avatar
  • 701
2 votes
1 answer
476 views

terminal fringes and diff-hl

I use diff-hl to highlight changed lines. However it doesn't play well in terminal mode. I know that terminal Emacs doesn't support fringes, and it is better to use diff-hl-margin-mode instead, it ...
user avatar
  • 21
2 votes
0 answers
328 views

Global display line numbers mode not working

I can run (display-line-numbers-mode) and get line numbers but it doesn't work if I run (global-display-line-numbers-mode) (nothing happens). I have traced this to this function: (defun display-line-...
user avatar
1 vote
0 answers
247 views

Show Git gutter after linenumbers

I am using emacs-nox and as some of you know there are always some problems if you want to display you line numbers while also using git-gutter. (Stuff like some extra margin jumping numbers etc.) ...
user avatar
  • 111
1 vote
1 answer
126 views

Hook when line number changes

Is there a hook which runs when the cursor position changes its current line numbers? For a concrete toy problem, can i highlight the current line as yellow when the line number of the current cursor ...
user avatar
11 votes
3 answers
8k views

Permanently display line numbers in emacs

I am asking this after having read this post: How do I display line numbers in emacs (not in the mode line)? I have tried using: M-x linum-mode and display-line-numbers-mode After closing emacs ...
user avatar
  • 211
3 votes
1 answer
364 views

Emacs 26 line numbers are ugly in empty buffers

I like that Emacs 26's line numbers are fast, but they seem to have a problem. If you open an empty buffer, there is an empty area which is reserved for line numbers: Once you add some text onto that ...
user avatar
  • 1,280
0 votes
1 answer
563 views

Unable to set relative line number as a default

I am trying to setup Emacs to have relative line numbering enabled by default via this plugin. According to the readme file Relative line numbering should already be enabled by default (by ...
user avatar
1 vote
1 answer
86 views

Number of lines the cursor is from the top of the screen when using hideshow.el

It's simple to find the number of lines from the cursor to top of the screen, eg: (- (line-number-at-pos (point)) (line-number-at-pos (window-start)))) However when the hideshow library is used to ...
user avatar
  • 7,179
0 votes
1 answer
62 views

How can I get a list of all of the line numbers of headers / subtrees in an Org-mode file?

E.g., with this input: * Test A thing! ** Testing * Hello Get this output: (1 3 4)
user avatar
5 votes
1 answer
1k views

disable line numbers in helm buffers , emacs 26

I have emacs 26 installed and helm. I would like to disable line numbers in helm buffers ( and other buffers that has no use of line numbers) is there anyway to disable the native line number in ...
user avatar
  • 185
2 votes
0 answers
2k views

Show both relative and absolute line numbers in Emacs 26

One of the new features in Emacs 26 is display-line-numbers-mode: Emacs now supports optional display of line numbers in the buffer. This is similar to what linum-mode provides, but much faster and ...
user avatar
  • 1,578
5 votes
0 answers
448 views

Making relative line numbers behave well with folds?

Context: I have relative line numbers displayed in emacs. If there is a fold (for example: in org-mode), these relative numbers appear to "jump". For example if I'm on line 0 over a fold, emacs could ...
user avatar
  • 807
1 vote
1 answer
884 views

How to turn on line numbering on modes that doesn't have by default?

I have spacemacs and when I edit a .py or .c file line numbering is turned on no problem, however when I open a .R file it isn't there (the mode is named ESS[S] to be precise). How can I turn it on ...
user avatar
0 votes
1 answer
183 views

How can I change the format of relative numbers?

I use this plugin relative-line-numbers of Fanael on Github. how to add extra spaces on the both sides of the relative number sides? Form this To this
user avatar
  • 51
3 votes
2 answers
1k views

Emacs relative and absolute line number at the same time?

I don't mean hybrid line number mode, I want the absolute line number appears for all the lines, not only the current line number.
user avatar
3 votes
1 answer
217 views

Preserve original line numbering for a narrowed region

I noticed that whenever I narrow a region in emacs, the line numbering is relative to the narrowed region rather than being relative to the original file. Is there any way I can preserve the line ...
user avatar
1 vote
3 answers
871 views

How to have both fixed linum and relative linum?

I installed linum relative with this. But installing this replaced my fixed linum. I want to have both fixed line number and relative line number as well. How can I do this?
user avatar
0 votes
1 answer
272 views

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

I have written the following bit of emacs lisp that allows hl-line to extend past end of buffer to the rest of the line. Problem is, this only works if I use (eval-buffer) after start-up and not when ...
user avatar
  • 67
12 votes
1 answer
524 views

How do I enable line numbers (on the left) every time when line is the long logical line

I have linum-mode enabled as well as truncate-lines. Works fine as long as Emacs displays column 0: The line number is showed on left (OK) But as soon as the window is scrolled horizontally, the ...
user avatar