Vim, empty and blank lines, executing commands on regexes, ^M

It’s been quite a while since I wrote something in the Bits and Pieces category. I’m forgetting that the goal of this blog was partly documenting my own knowledge for my own use.Definitely need to hide this category from the front page and use it often. Or even better, make it a category on the wiki.

That said:

Vim digraphs

^M is how vim shows the 0xD character, which in Windows is a newline character. A more complete list of such characters is here:

One way to insert such characters would be: ^M is entered by holding down Ctrl and typing v followed by m, and then releasing Ctrl. 1

Interestingly enough, the keys above are represented via the <kbd> tag, which apparently is a thing:2

The HTML <kbd> element represents user input and produces an inline element displayed in the browser’s default monospace font.

Vim removing empty lines & executing a command on lines matching a regex

:g will execute a command on lines which match a regex. The regex is ‘blank line’ and the command is :d (delete) 3

Also interesting is the distinction between blank lines and empty lines. They could be defined as just '\n' and as a line with various spaces, but on visible content.

Footnotes   [ + ]


Leave a Reply

Your email address will not be published. Required fields are marked *