CMB
CMB

Reputation: 4145

Quicker way to enter ex mode in vim?

Is there a somewhat orthodox way to enter ex mode faster, like with a single key stroke, instead of hitting shift-; for ':'? Why was that character ever chosen for such a frequently accessed mode? Often enough to be annoying I'll accidentally miss the shift key, start typing an ex command, and find I have a lot to undo. Thanks for your suggestions. :)

Upvotes: 5

Views: 3424

Answers (5)

ruohola
ruohola

Reputation: 24038

Finnish keyboard has , ; in one key and an other key with the symbols . :. I have these following mappings to make using them a lot easier:

noremap , :
noremap : ;
noremap ; ,

if has('terminal')
    tnoremap <C-W>, <C-W>:
endif

This way I can simply press , to get to command-line mode, and I can move to next/previous search of f with shift-, and shift-..

Finnish keylayout

Upvotes: 0

random
random

Reputation:

I switched the semicolon character with the colon character.

noremap : ;

noremap ; :

So now, to enter Command mode, I just press ; (no Shift) and do : (Shift + ;) for reapeating forward a f or t search.

Upvotes: 2

Bryan Alves
Bryan Alves

Reputation: 619

Typing ':' doesn't put you into ex mode, it puts you into command mode. I'm not sure if this is a default keybinding, but "Q" puts me into ex mode.

As for a faster way of getting into command mode, it doesn't get much faster than a single keystroke. I would recommend just taking a little bit of time to get used to it.

Upvotes: 4

michael
michael

Reputation: 11847

rather than making a quick macro just to enter : you might want to automate whatever you're rushing to do all the time. Little tricks like this add up.

I find double slash as an easy leader. (a lot of plugins map single \ )

eg I have

nnoremap \\t :vert stag <-- opens tag of current word in vertical window

nnoremap \\g :vimgrep **/* <-- searches code tree for word under cursor

nnoremap \\w :w

etc

Upvotes: 4

Brian Carper
Brian Carper

Reputation: 72926

Set up your own mapping. e.g.

nmap <Space> :

Now spacebar in Normal mode takes you to the command line. However personally I don't find : hard to type. You get used to it after a few months of Vimming.

Upvotes: 11

Related Questions