Skip to main content
12 events
when toggle format what by license comment
Nov 13 at 20:21 vote accept Diego Comfort
Nov 8 at 14:39 answer added saulotoledo timeline score: 1
Sep 23, 2024 at 10:21 answer added lawlist timeline score: 1
Sep 20, 2024 at 3:32 comment added Diego Comfort Yeah, I guess it's just what it is. But it's weird because Vim shows the number of an empty line
Sep 20, 2024 at 0:07 comment added db48x This is one of the weirder edge cases in computing. Nobody can really agree on it, but POSIX did weigh in on the matter. The POSIX definition of a line is a sequence of characters followed by a newline character. Thus the newline character does not separate lines of text, it terminates lines of text. If you add some characters after the final newline, many programs won’t count it as a line. Try running printf "foo\nbar" | wc -l, for example.
Sep 19, 2024 at 18:09 history edited NickD CC BY-SA 4.0
edited title
Sep 19, 2024 at 13:18 comment added lawlist If I remember correctly, there is either a bug report or a discussion on the Emacs Devel mailing list between Eli Z. and myself from several years ago where he stated that the end of the buffer on a line all by itself (without a line number) is "a feature". In my tinkering with the C source code back then, I created a test for no man's land and use a custom indicator at that location -- however, that is not a part of the standard Emacs and was never incorporated. Maybe someday I will pick-up that project again ...
Sep 19, 2024 at 5:26 comment added phils (Not that I know for sure that both features were implemented with the same interpretation -- display-line-numbers-mode came along decades after line-number-mode -- but I believe the above is very much the reasoning for how display-line-numbers-mode behaves.)
Sep 19, 2024 at 5:20 comment added phils The mode line is forced to show the next number because it only shows one value, and so it needs a way to differentiate between the last line of the buffer and where the cursor is now -- it would be confusing, otherwise. You can think of the mode line as showing the potential line number, and the left edge as the actual number of lines in the buffer.
Sep 19, 2024 at 5:20 comment added phils It's by design because there is no "last empty line" -- I can't think of any software which would read a file with a final newline and treat it as an additional line. (Something might do it, but it would be weird.) If you have a file with three lines and each line ends with a newline character, pretty much everything is going to call that "three lines" rather than "four lines".
S Sep 19, 2024 at 3:44 review First questions
Oct 3, 2024 at 3:51
S Sep 19, 2024 at 3:44 history asked Diego Comfort CC BY-SA 4.0