martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.2k stars 258 forks source link

Allow lateral cursor movement while in line mode #625

Open mqudsi opened 6 years ago

mqudsi commented 6 years ago

Apologies in advance if this was a deliberate decision

Imagine the following code opened in vis:

fn function() {
    foo();
}

with the cursor on the first character of the first line in normal mode, pressing V enters visual line mode. In vis, at this point the cursor is disabled and navigation is by line only. In vim, the cursor is still present and allowed to travel not only in the y direction (which is allowed by vis and changes the selected lines) but also in the x direction, which sets the token that navigation commands will apply to.

e.g. in vim, after having pressed V it is possible to navigate along the x-axis to the last character in the line (the { symbol), at which point one has the option of pressing % to visually select all lines from the current line to the matching } symbol.

Since the cursor is disabled in vis while in visual line mode, this is not an option.

martanne commented 6 years ago

This was actually possible in older versions when the internal representation was a cursor with an optional selection. Starting with 708216769c7cdf02ce3f69785a4356efd7dea0f7 the model changed, cursors were superseded by singleton selections. As a consequence we only track the two selection endpoints.

Overall I think this was a worthwhile simplification, but it precludes the functionality you request. As a workaround you will have to switch in and out of character wise visual mode.