This is a feature that notepad++ has: when in a wrapped line, the first press of <Home>
sends you to the beginning of the wrapped line. The second press sends you to the beginning of the text (soft BoL), and the third sends you to the true beginning of the line (hard BoL). After that, pressing <Home>
toggles between soft BoL and hard BoL.
Similarly, pressing <End>
inside of a line wrap sends you to the end of the wrapped line on the first keypress, and to the true end of the line after that.
Here is an example:
1 | // Code that generates Lorem Ipsum
2 | if (true) {
3 | return "Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed d* eiusmod tempor incididunt
ut labore et dolore magna aliqua";
4 | else { return ""; }
Thus, if my cursor was at the star (*
) in the "2nd" line of line 3, I would want pressing <Home>
to send me to the 'a' of "adipiscing." I know that this can be done with g^
. However, I want the next keypress to send me to the 'r' of "return," which is equivalent to ^
. Then, another keypress should put me before the indentation, equivalent to 0
. Pressing <Home>
again at this point should return me to the 'r' as if I had pressed ^
. Afterwards, the cursor should toggle between 'r' (the first non-whitespace character) and the first character in the line.
If, instead, with my cursor at the star (*
), I pressed <End>
, it should be equivalent to g$
, landing on the 't' of "incididunt." Another press should bring me to the semicolon at the end of the line.
The difficult part of this is that vim seemingly does not store the wrapped lines, meaning I can' determine where a line starts or ends.
r
eturn back to virtual column 1. It would just toggle, something like the behavior of this: vi.stackexchange.com/questions/23205/…