Vim: Is there a downside to using <Space> as your <Leader> key?

24

2

I recently started using <Space> as my mapleader, and I find it very comfortable and fast. I can slap that key with either thumb, freeing up whichever hand I need for the next keystroke, and even one-handed combos are pretty easy. I'm curious why I haven't heard more Vim users recommend this. Is there a downside I'm missing? I see a lot of people recommending , but that feels awkward to me for a lot of combos.

ivan

Posted 2013-12-26T23:34:20.810

Reputation: 855

Question was closed 2013-12-27T16:48:23.907

Answers

29

I use space as my leader and love it. I've found that for me, (with their default actions) , is occasionally useful and <space> is literally never useful.

I can't think of any downsides to the spacebar,* and likewise have no idea why , is so apparently common.

* Except for one easily-solvable one. Space doesn't appear for 'showcmd'. I work around this by using \ as my leader and mapping (must be :map, not :noremap) space to \.

pandubear

Posted 2013-12-26T23:34:20.810

Reputation: 406

2Found the tip for 'showcmd' helpful. One problem I ran into which I wasn't able to come up with a work around for was with that mapping it didn't seem possible to invoke keybindings mapped to <leader><leader>[key] – Mike S – 2014-08-22T18:55:19.117

1Space does appear as <20> in the "showcmd" for me. (I'm using gVim for Windows version 7.4, patches 1-1965) – Niko Bellic – 2016-08-31T17:28:30.230

@pandubear What do you like <space>x as i? It seems longer, although it is left handed. – Casey Rodarmor – 2017-02-07T06:47:51.273

1@rodarmor It was just an example for debugging ivan's problems. – pandubear – 2017-04-25T18:53:23.907

Nice workaround! I'm going to try this. – ivan – 2013-12-27T16:50:57.973

It's not working for me. The mapping works, but showcmd doesn't show \ when I hit <Space>. Am I missing something? – ivan – 2013-12-27T17:05:26.640

Hmmm... Here's the minimal version of what I did. map <Space> <Leader> ** nnoremap <Leader>x i ** set showcmd. (replace the **s with newlines since comments have to be one line) Use that as your vimrc. Does it work? On my machine, I'm able to use <space>x as i, and \ appears when I hit the spacebar. – pandubear – 2013-12-27T21:27:56.053

I tried it again, and it seems to work if I start a new Vim session. I tried to isolate it but couldn't figure out what was interfering. Anyway, it works now. Thanks! – ivan – 2013-12-29T03:37:21.830

3

It doesn't take long to get used to , (compared to the default \ anyway). However, given that most people map their leader-key to ,, some plugins (nerdcommenter for example) are written with this in mind and using <Space> may interfere with some functionality. If you can live with that, go for it.

krystah

Posted 2013-12-26T23:34:20.810

Reputation: 1 337

When having space as the leader doing <space>c<space> still works for toggling the comments, so it doesn't seem like an issue. – fbence – 2019-11-29T15:25:42.447

2

I have been comfortable using ; as the leader. It helps the fingers stay on the home row and has been easy enough to use. But now, space seems to be a good option too. It doesn't conflict with my workflow. I'll probably give it a try.

Sriharsha

Posted 2013-12-26T23:34:20.810

Reputation: 31

4You should definitely ditch ; for space. ; is the command for "jump to next f/t-result. I find it very useful. – krystah – 2013-12-27T05:36:01.283

I haven't used f or t a lot. So, ; has worked for me all along. Using space instead of ; will be the first thing I'll try after the holidays. – Sriharsha – 2013-12-28T06:41:49.277

1

I don't know why I've never heard anyone else use <space> for mapleader. It makes sense to me as long as you don't use <space> for navigation, which I don't either. I can't think of any other disadvantage.

garyjohn

Posted 2013-12-26T23:34:20.810

Reputation: 29 085