Questions tagged [line-numbers]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
521 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, ;; ...
0 votes
2 answers
1k 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?
1 vote
1 answer
79 views

Position `display-line-numbers-mode` to the left when using `visual-fill-column-mode`?

I am very new to the world of Emacs and therefore I'd like to ask of everyone to be kind, not that I am expecting any flame or hate. (just a reminder) I was recently recommended to use visual-fill-...
0 votes
1 answer
44 views

`line-number-mode`, but per-buffer (using `smart-mode-line` package)

Is it possible to have the line number where the cursor is shown in the mode-line (or line and column numbers appearing in the buffer) only for certain buffers, while it is disabled for other buffers. ...
0 votes
1 answer
56 views

View window shifts to right when scrolling to the bottom

I recently starting using vanilla emacs, specifically for org mode. I noticed something odd happening when I try to display line numbers in my files. Near the top of the file, the line numbers are a ...
1 vote
1 answer
38 views

With evil keybindings, how do I navigate using actual lines only if a count is involved?

Before moving to Emacs, I had a Vim setup that included the functionality to navigate between visual lines with j and k by default, but if there was a count involved (e.g. 20j), "regular" ...
72 votes
9 answers
83k views

How do I display line numbers in emacs (not in the mode line)?

I know how to display line numbers (and columns) in the mode-line, but I'd like emacs to display the line numbers for all the lines on the left-hand side. I've seen this done in vim and other text ...
0 votes
0 answers
27 views

Mixed display-line-numbers-type for evil users?

I want something like: (setq display-line-numbers-type 'mixed) Which count wrapped line as "relative", and count folded line as "visual" Is there any way to achieve this? Say I ...
1 vote
1 answer
48 views

M-g M-g <nnn> to end of line (C-e)?

I often have to use this sequence: M-g M-g <nnn> C-e to get to the end of a particular line, for example to place a % or \par in TeX files. Is there some way to combine this into, say (...
0 votes
1 answer
35 views

How to remove (customize) the color of the bar from global-display-line-numbers-mode?

I want to use relative line numbers and therefore I turned on this mode: Global Display Line Numbers Mode. When I want to customize this variable, there is no option in customizing the color of the ...
1 vote
1 answer
128 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 ...
0 votes
1 answer
104 views

Can one enable display-line-numbers in buffer's startup?

How would one enable line numbers on a buffer basis? What I have in mind is a statement in the preamble of the buffer of this form: #+STARTUP: [...(turn on line numbers)...]
3 votes
2 answers
119 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?
1 vote
1 answer
380 views

Copy with Line Numbers

I have line-numbers displayed, but when I copy the text, the normal behavior is of course to not include the line numbers in the copied text. However, when I want to paste something on sites like this ...
1 vote
2 answers
360 views

Constant Font Size In `display-line-numbers-mode` When Zooming In And Out

SOLVED The atom-one-dark theme that I was using was the issue. (add-to-list 'custom-theme-load-path "~/.emacs.d/themes/atom-one-dark") (load-theme 'atom-one-dark t) My init.el: (menu-bar-...
0 votes
0 answers
31 views

Relative numbers, bouncing text?

when I put relative numbers on, I get bouncing text when I move up an down. I have short files where this is an issue, so it's not the number length. The entire line reshapes depending on the "...
0 votes
1 answer
78 views

How to set relative line-number digit width?

I have set my number line relative to cursor as such: (global-display-line-numbers-mode 1) (setq display-line-numbers-type 'relative) But, In a long file with line-difference more than 4digit (1000+),...
0 votes
1 answer
501 views

How do I configure Emacs to display of line numbers permanenty [duplicate]

https://www.gnu.org/software/emacs/manual/html_node/efaq/Displaying-the-current-line-or-column.html M-x (global-display-line-numbers-mode) But after I do C-x C-c then it's not configed. How do I make ...
3 votes
1 answer
630 views

Setting width of relative-line-numbers

I am using the relative-line-numbers-mode and a 90 degree turned screen, which makes the text jump when it goes from displaying 100 in the relative number. Is it possible to set a fixed width for ...
0 votes
1 answer
76 views

Problem With Linux Mint Cinnamon Display of Lines Numbers and Mode Line

Addendum added to respond to the answer and subsequent comments of db48x A few months ago, I migrated from Fedora to Linux Mint 20 (Cinnamon), and then installed Emacs v26.3 in Mint. As shown in the ...
0 votes
1 answer
129 views

Is it possible to get the line number of the nearest regex match above the current cursor position?

I'd like to write an elisp function that tells me the line number of the closest regex match above my current cursor position. For example, if my cursor is on line 9 of the following file and my regex ...
0 votes
0 answers
42 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?
1 vote
1 answer
93 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 ...
0 votes
1 answer
91 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)?
5 votes
0 answers
92 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). ...
1 vote
0 answers
18 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
0 votes
1 answer
88 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 ...
16 votes
3 answers
11k 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 ...
1 vote
1 answer
74 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 ...
1 vote
1 answer
109 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-...
22 votes
3 answers
4k views

A faster method to obtain `line-number-at-pos` in large buffers

The function line-number-at-pos (when repeated about 50 times) is causing a noticeable slow-down in semi-large buffers -- e.g., 50,000 lines -- when point is near the end of the buffer. By slow-down, ...
3 votes
2 answers
2k 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.
0 votes
1 answer
90 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 ...
0 votes
1 answer
284 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-...
0 votes
0 answers
41 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,...
0 votes
1 answer
405 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-...
2 votes
1 answer
233 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 ...
0 votes
0 answers
285 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 ...
2 votes
1 answer
771 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 ...
2 votes
2 answers
736 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 ...
1 vote
2 answers
87 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 ...
4 votes
1 answer
1k 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 ...
4 votes
1 answer
873 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 ...
7 votes
2 answers
3k views

Any way to get a working separator line between fringe/line numbers and the buffer?

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 ...
8 votes
1 answer
5k 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 ...
1 vote
1 answer
180 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 ...
4 votes
1 answer
779 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 ...
1 vote
0 answers
119 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 ...
0 votes
1 answer
157 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 ...
4 votes
0 answers
259 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 ...