Skip to main content
26 votes
Accepted

How to count the number of lines in the region?

M-= (command count-words-region). (The region does not even need to be activated, but activating it lets you see it.)
manandearth's user avatar
  • 2,138
5 votes

How to count the number of lines in the region?

Count lines does the trick, it is defined in simple.el (count-lines (point-min) (point-max))
Sebastian G.'s user avatar
2 votes

Show only one or two lines of a buffer

C-hv window-min-height The minimum total height, in lines, of any window. The value has to accommodate one text line, a mode and header line, a horizontal scroll bar and a bottom divider, if present....
phils's user avatar
  • 51.8k
2 votes

How to get line number for a given buffer position in a performant way?

For a faster method to get line number at position -- (with-current-buffer BUFFER (goto-char POSITION) (string-to-number (format-mode-line "%l"))) -- see the following thread, which cites some ...
lawlist's user avatar
  • 19.2k
2 votes

Delete duplicate lines, with partial match

Try delete-duplicate-lines, which is part of distributed Emacs. Emacs Wiki page Duplicate Lines might help. It points to a blog post about it. It explains why interactive search-and-replace might ...
Drew's user avatar
  • 78.1k
2 votes
Accepted

Sorting lines based on numbers in unicode

Use seq-sort-by instead of sort-regexp-fields. Therewith, you can specify a function to extract the key from the strings and a sort function. In your case string< fits as lexicographical sort ...
Tobias's user avatar
  • 33.4k
2 votes

Sorting lines based on numbers in unicode

EDIT To also sort the string with the pattern you gave in the comments (but alternated with a variable number of words), you can use the following function to split the strings, and use it('s result) ...
dalanicolai's user avatar
  • 7,890
2 votes

Is arbitrary buffer position at the beginning of a line?

You can also use the function bolp: bolp is a built-in function in `../editfns.c'. (bolp) Return t if point is at the beginning of a line. This function does not change global ...
xuchunyang's user avatar
  • 14.6k
1 vote

How to remove trailing '$' character

See the Emacs manual, node Line Truncation: As an alternative to continuation, Emacs can display long lines by “truncation”. This means that all the characters that do not fit in the width of the ...
Drew's user avatar
  • 78.1k
1 vote

What is the default value of TRY-VSCROLL in `(previous-line &optional ARG TRY-VSCROLL)`?

Didn't read all your comments. But the doc string says two things that are relevant: (1) ARG defaults to 1 and (2) this command is only for interactive use. However, IMHO, it would be better if the ...
Drew's user avatar
  • 78.1k
1 vote
Accepted

Count unhidden lines from hide-lines?

C-h f count-lines says: (count-lines START END &optional IGNORE-INVISIBLE-LINES) ... When IGNORE-INVISIBLE-LINES is non-nil, invisible lines are not included in the count. So, in order to count ...
NickD's user avatar
  • 31.4k
1 vote

Undo one specific line in a text file within Emacs

See C-hig (emacs)Undo: When there is an active region, any use of undo performs selective undo: it undoes the most recent change within the region, instead of the entire buffer. However, when ...
phils's user avatar
  • 51.8k
1 vote

Unrestricted movement of lines Alt-Up/Down

Name and documentation of this function says it all: Signature (org-shiftmetaup &optional ARG) Documentation Drag the line at point up. In a table, kill the current row. On a clock timestamp, ...
Heikki's user avatar
  • 3,076
1 vote
Accepted

Show only one or two lines of a buffer

The following shows one line of content and the modeline for me: (setq window-safe-min-height 0) (setq window-min-height 0) I would love to have a way to make the content completely collapse for an ...
Rune Kaagaard's user avatar
1 vote

Show only one or two lines of a buffer

Would it suit your purpose if you had a command which searched for the next line in the buffer which has a number in it and then showed you just that line? (defun go-to-next-line-with-number () (...
Aidan Schofield's user avatar
1 vote

Delete duplicate lines, with partial match

If you don't need to do this all the time, the quickest solution might be using interactive replacement: query-replace-regexp, bound to C-M-%. Start with point at the top of the buffer. Note, if you ...
Tyler's user avatar
  • 22.4k

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