On 2021-07-12, Bram Moolenaar wrote: > > > **Problem** > > Often times, especially when coding (and presumably the user base of vim > > are mainly developers), it would be useful to move selected text either > > to the left or to the right by n chars, or alternatively, if no text is > > selected the char over which the caret currently is. However, according > > to my knowledge, this can currently only be performed using a workaround > > of deleting (→ implicitly copying) and pasting the expected text. > > > > For its vertical counterpart, there exists a method to do so: > > ```vim > > :m+/-<number of lines to move>, i.e. :m+5 > > ``` > > > > **Solution** > > Add a currently unused key combination to perform this action. > > There are two possible approaches: > > a) like the vertical approach: use another `final mode`, something like > > ```vim > > :mh+/-<number of chars to move> > > ``` > > where `+` would shift right for scripts reading from left to right, > > such as English, and `-` would move left. > > The question is then whether to invert the direction moved for scripts > > reading from right to left, or not. (In favor: Most likely easier to > > understand for RTL scripts, Contra: Way harder to implement (how do > > you detect if you currently write LTR or RTL?)) > > > > b) a `normal mode` command, i.e. something like `m5r` to move 5 > > characters to the right and `m5l` for the opposite. Most likely easier > > to implement, integrates most likely better into the current system > > (i.e. because it allows for calls like `m2F(r` or similar > > shenanigans), and is less confusing as the differentiation between RTL > > and LTR scripts does not need to be made. > > Interesting idea. We could perhaps use "g>" to move right and "g<" to > move left. In Visual mode these are currently an error. > > To make it a bit more convenient, we could use "g>>>" to move three > positions. Thus each extra ">" moves one more character.
How about using a numeric prefix for the number of columns/characters to move? That would leave the operator-pending syntax the same as other operator-pending commands. E.g., "3g>w" would move everything from the cursor to the end of the word right by 3 columns; "g<f;" would move everything from the cursor through the next semicolon left by 1 column. In normal mode, though, g< already means "display previous command output". Regards, Gary -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/20210712193954.GA13481%40phoenix.
