Ads by Google

Wednesday, June 20, 2012

Numbering Lines and lists in Emacs

I'm not talking about Line Numbering as we usually understand it but more along the lines of numbering lists or text inside the file buffer and which are part of the file. err...best to use the wiki definition again;NumberLines

In Emacs 24.1, the NEWS file had this new addition to the rectangle commands.


** New command `C-x r N' (`rectangle-number-lines') numbers the lines in the current rectangle.  With a prefix argument, this prompts for a number to count from and for a format string.



This allows you to now number lines or lists easily instead of using a macro or additional elisp functions.  Mark a vertical region of text(using transient mark mode may help) 1 character wide and then hit C-x r N and that's it.  It numbers the line.

If you use the prefix command C-u and do C-u C-x r N, it will prompt you for a starting digit and the format string, so you can start from 15, say.

Things do get better with Emacs!