0

By keys I mean like being Normal mode and pressing e (takes you to end of [next] word), by commands I mean like being in Normal mode and pressing Shift+; and typing :delete.

For example: after entering select mode, I would like to be able to press Ctrl+e to jump to the end of the line, selecting everything in between as I go, the equivalent of being in Visual mode and pressing: Shift+$. Is there something I can put in my .vim file that would make that work ? I tried this:

snoremap <C-e> <S-$> and snoremap <C-e> execute "visual! <S-$>"

but they both don't work. The first one replaces the selection with a $ in the text and the second one replace the selection with visual! $.

Or for example copying the selection, the equivalent of being in Visual mode and pressing y. I tried: snoremap <C-c> y, but this just replaces the selection with a y.


Intent behind this

I kinda of just want to use select mode to perform selections like in normal (GUI) editors, be able to select text with Arrow and Alt+Arrow, but also with Ctrl+[a|e] for jumping to front/end of line and then be able to copy/delete/move/duplicate-up/down the selection, but then also just be able to start typing replace the selection. Ik you can just basically do all that with Visual mode but to replace the selection there's an extra step involved, which is first delete the selection and enter insert mode, then start typing.

3
  • Much better. I am kind of wondering why you want to treat Select like Visual rather than just using Visual. Select's primary reason for being is to emulate GUI selections. So if you type anything when text is select it will be replaced. Trying to subvert that seems like a path to disappointment. ;) Welcome to Vi&Vim SE, BTW. (I don't mean that ironically. :)
    – B Layer
    Nov 19 '20 at 17:40
  • By the way, if this can't be done, I guess it's fine, I'll stick to Visual mode. It's just out of curiosity, maybe someone experienced could quickly say if it's possible.
    – Akharrou
    Nov 19 '20 at 17:52
  • "An extra step"--meet c, your new friend :) (:help v_c says "Delete the highlighted text and start insert")
    – D. Ben Knoble
    Nov 19 '20 at 20:04
1

By keys I mean like being Normal mode and pressing e (takes you to end of [next] word), by commands I mean like being in Normal mode and pressing Shift+; and typing :delete.

Yes. From Select mode, you can use CTRL-O to switch to Visual mode for the duration of a single command.

So you can use <C-o>e to select until the end of the word, or <C-o>:delete<CR> to delete the lines spanning the selection. (The latter appears as :'<,'>delete, since : from Visual mode will automatically default to these bounds.)

After entering select mode, I would like to be able to press Ctrl+e to jump to the end of the line, selecting everything in between as I go, the equivalent of being in Visual mode and pressing: Shift+$. Is there something I can put in my vimrc file that would make that work?

Yes, you can use the following mapping:

snoremap <C-e> <C-o>$

And if you want one for the beginning of the line:

snoremap <C-a> <C-o>^

Or perhaps:

snoremap <C-a> <C-o>0

Depending on which definition you like best.

Or for example copying the selection, the equivalent of being in Visual mode and pressing y.

Same idea:

snoremap <C-c> <C-o>y
1
  • 1
    Works perfectly. Thanks
    – Akharrou
    Nov 22 '20 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.