Hot answers tagged

15

M-= (command count-words-region). (The region does not even need to be activated, but activating it lets you see it.)


2

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 state, including the match data. Usually you get a buffer position via (point), thus simply issuing (bolp) will be enough. If the point has been moved, use goto-...


2

Count lines does the trick, it is defined in simple.el (count-lines (point-min) (point-max))


2

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 not help. It explains how to do it with Lisp, in various ways. It explains how to do it with the UNIX / GNU/Linux command sort or unique.


2

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. A value less than ‘window-safe-min-height’ is ignored. The value of this variable is honored when windows are resized or split. I found this with M-x ...


1

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 () (interactive) (widen) (unless (bobp) (end-of-line)) (when (search-forward-regexp "[0-9]" nil 0) (save-excursion (narrow-to-region (...


1

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 limitations / disadvantages in the comments: A faster method to obtain `line-number-at-pos` in large buffers The traditional method is to use line-number-at-pos, ...


1

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 want to delete entire lines, you'll need to include a newline in your regexp. You enter this at the prompt with C-q C-j. So, for over_second, call C-M-%, then ...


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