1

I noticed using evim that when I press Shift key plus any direction key (so <S-Up>, <S-Down> etc., the editor automatically switches to insert-select mode, letting me select the text block with direction keys.

Since I think this mode is more handy than typing ESC, v, etc. each time, I tried to replicate this behavior using shortcuts with gvim, for example

:imap <S-Up> <Esc>:v<Up>

without success. No way.

How can I replicate this evim's behavior in gvim ? Is this possible ?

2 Answers 2

4

The option which controls this behavior is keymodel. In evim, it is set to startsel,stopsel. From :help 'keymodel;

   startsel     Using a shifted special key starts selection (either
        Select mode or Visual mode, depending on "key" being
        present in 'selectmode').

   stopsel      Using a not-shifted special key stops selection.

Here, "special key" means arrows, end/home, pageup/down.

You can simply use set keymodel=startsel if you prefer not to cancel the selection when not pressing shift.

When using this option, vim will by default enter visual mode unlike evim, which enters select mode. You can instead enter select mode in this case by using the additional option,

set selectmode+=key
1
  • @simo-zz Remember to mark the answer as "accepted" that is useful for future users reading your question :)
    – statox
    Dec 13, 2017 at 12:24
2

You need to remove : in :v because you don't want to use the command :v which is the negation of :g, you want to press v in normal mode:

:imap <S-Up> <Esc>v<Up>

(Also you should use inoremap it is much better to avoid unwanted behaviors)

7
  • I already tried this also and it doesn't change the behavior.
    – xyx
    Dec 12, 2017 at 15:35
  • @simo-zz I just tried it on my system and it works properly. Have you tried replacing imap by inoremap? And what happens when you press <S-Up> in insert mode after you set your mapping?
    – statox
    Dec 12, 2017 at 15:40
  • 1
    Alternatively, set keymodel=startsel, then no map is necessary
    – Mass
    Dec 12, 2017 at 15:48
  • @Mass I had never seen this option before it is totally worth an answer! :)
    – statox
    Dec 12, 2017 at 15:54
  • 1
    Yep sorry. Thank you @Mass and statox as well for your help.
    – xyx
    Dec 12, 2017 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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