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 ...?

Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37
ThiefMaster
  • 173
  • 4

3 Answers3

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.

Ingo Karkat
  • 17,819
  • 1
  • 45
  • 61
  • 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....

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271
  • 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 08 '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
lindhe
  • 477
  • 4
  • 15
Luc Hermitte
  • 17,351
  • 1
  • 33
  • 49