0

New to Vim here; did several searches on how to do this in Vim, but without any luck (maybe it's too simple).

I'm attempting to highlight words in sequence, in the same way that SHIFT + OPTION + [Arrow Key] does for Macs.

Is this doable in Vim? Would love to be able to in "Insert" mode and not be in "Visual" mode for that.

2

You can do this by running

:behave mswin

This command will simultaneously change several commands, namely "selectmode", "mousemodel", "keymodel", and "selection". I would recommend reading the help page on each of these, since they're all related to what you want to do but affect it in slightly different ways.

From :h behave

3. Mouse Control                                        gui-mouse

The mouse only works if the appropriate flag in the 'mouse' option is set.
When the GUI is switched on, and 'mouse' wasn't set yet, the 'mouse' option is
automatically set to "a", enabling it for all modes except for the
hit-enter prompt.  If you don't want this, a good place to change the
'mouse' option is the "gvimrc" file.

Other options that are relevant:
'mousefocus'    window focus follows mouse pointer gui-mouse-focus
'mousemodel'    what mouse button does which action
'mousehide'     hide mouse pointer while typing text
'selectmode'    whether to start Select mode or Visual mode

A quick way to set these is with the ":behave" command.
                                                        :behave :be
:be[have] {model}       Set behavior for mouse and selection.  Valid
                        arguments are:
                           mswin        MS-Windows behavior
                           xterm        Xterm behavior

                        Using ":behave" changes these options:
                        option          mswin                   xterm   
                        'selectmode'    "mouse,key"             ""
                        'mousemodel'    "popup"                 "extend"
                        'keymodel'      "startsel,stopsel"      ""
                        'selection'     "exclusive"             "inclusive"

So after running :behave mswin, you can select individual characters in insert mode with <shift-cursor_keys>, and entire words with <ctrl-shift-cursor_keys>.

Note that even though what you want is definitely possible, I would recommend learning to use visual mode instead. Since it is more "vim-like", it will be more compatible with other vim-idioms and make you much faster.

Of course, it's your workflow, so in the end it's all up to you. :)

  • Thanks, worked! But I'll definitely try to use it in visual mode instead. It's just kind of a pain in the butt having to press esc every time to switch modes. – fibono Oct 28 '16 at 18:29

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.