0

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 ?

3

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
  • @simo-zz Remember to mark the answer as "accepted" that is useful for future users reading your question :) – statox Dec 13 '17 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)

  • I already tried this also and it doesn't change the behavior. – simo-zz Dec 12 '17 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 '17 at 15:40
  • 1
    Alternatively, set keymodel=startsel, then no map is necessary – Mass Dec 12 '17 at 15:48
  • @Mass I had never seen this option before it is totally worth an answer! :) – statox Dec 12 '17 at 15:54
  • 1
    Yep sorry. Thank you @Mass and statox as well for your help. – simo-zz Dec 12 '17 at 16:07

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.