Posts

Showing posts from August, 2022

Vim: Study on constructing Regular Expressions to delete or reduce blank lines with Global Command

Image
Preface On the topic of this article you may find interesting the following one: “Vim and Regular Expressions for removing redundant whitespace” . Unlike the previous article, here the presence of whitespace causes different solutions than blank lines regardless of the number of their occurrences. The study in this article is focused on both the analysis of “ regular expressions ” and Vim’s global command. Vim and the Global Command The Global Command in Vim is the g key. It’s useful for a lot of purposes. In Normal Mode it can be used to compose multi-letter commands, such as the following ones: guw : lower case next word gUw : upper case next word gU2w : upper case next two word gUe : upper case until the end of the word gu$ : lower case until the end of the line ge : move to the end of the previous word (simple e moves to the end of the next word) … and so on. The g Command can also be a motion operator , as described in this article of mine . The same global

What is intended by "line" in Vim? How to configure a dual alternate mode of movement between lines.

Image
Why is the Vim line definition “special”? In Vim a “line” is a set of characters that ends with a return line. Is that all? It seems obvious, but how does it differ from the definition of “line” in other writing systems? Simple: in other environments usually “lines” break at the right margin of the monitor. In Vim they don’t. Nothing changes for short lines, that is, lines that do not exceed the margin right margin. It changes, however, in the case of long lines that exceed that edge. For Vim, therefore, the line object can be, in monitor, displayed on multiple visual lines. Movement between lines in Vim? In the default configuration of Vim, vertical moves occur using the keys corresponding to the letters j and k or with the arrow keys and take effect on entire lines, as defined above. Vertical moves between lines exceeding the edge of the monitor, however, require the letter g before j and k motion operators: thus gj or gk . The rule also applies to operations o