7

I quite often start typing the s before fully releasing the shift key, and having to correct the command afterwards is a bit annoying.

Is there any way to make :Set ... an alias for :set ...?

  • I have this exact same problem with :sp, :vs and :e – Shahbaz Mar 21 '15 at 12:57
14

While you cannot define custom commands starting with lowercase characters (like the built-in ones), nothing prevents you from doing the opposite, defining user commands that mirror the built-in ones.

:command! -nargs=* -complete=option Set set <args>

If you do this for additional commands, just ensure the number of arguments / taken :range / bang ([!]) matches. See :help :command-nargs (and following paragraphs) for the available options.

Warning

Sloppy typing won't get you very far with Vim; instead of relying on such workarounds (which don't work as well in other areas like mappings and motions), better deliberately slow down for a period of time and work on your typing precision. Investing in a higher-quality keyboard might help, too.

| improve this answer | |
  • I do have a decent keyboard (WASD with mx clears). But in many cases I just fire up gvim from my task bar (yeah, windows user, no comment :p), :set syntax=whatever and then switch to insert mode if i need a code scratchpad for something. – ThiefMaster Mar 21 '15 at 14:07
5

You could remap ; to :, that way there's no more Shift key involved:

:noremap ; :

This has the obvious downside of losing the function of the ; key ("Repeat latest f, t, F or T [count] times."), to map this to : (and thus swapping ; and :), you can use:

:noremap ; :
:noremap : ;

The problem with that, though, is that once you're used to it, you'll be semi-crippled in a default Vim installation....

| improve this answer | |
  • This is a good idea actually, the fewer times shift is used the better. Also, I hear you regarding getting semi-crippled. I have swapped my 1..90-= keys with their alternatives !..()_+ in C, C++ and Haskell files since the alternatives are used much more frequently and it's really nice, but I do get semi-crippled when using vim where my settings are not in effect. – Shahbaz Mar 22 '15 at 14:06
  • Using command abbreviations and omitting unnecessary spaces following command would swap : and ; on a default installation to not be semi-crippled: :no; :|no: ;<cr> (12 characters have to be typed). – Hotschke May 8 '19 at 11:49
3

You can simply define an abbreviation.

:cab Set set

As carpetsmoker mentioned this will replace Set with set everywhere in the command line. To avoid this use

:cnoreab Set set
| improve this answer | |
  • 5
    Note that this will replace Set with set everywhere in the command line, not just when you type :Set – Martin Tournoij Mar 22 '15 at 16:09

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.