I don't use any g combinations except of gg, in normal mode. How can I make it so that pressing g once will be enough?

nnoremap g gg makes it wait for 3 seconds or so for a continuation of the command. Unmapping g beforehand doesn't work either, because I can't map to gg if I unmap g. Should I unmap every single combination that isn't gg?

  • 7
    Just because you don't use any g mappings now, does not mean you wont use any in the future. There are some rather handy ones in there. e.g. gE, g_, gt, gT, g,, g;, gu, gU, gn, and my personally favorite gf. See :h g for a list of all g mappings. Commented Dec 2, 2015 at 16:12
  • Oh yes, gf is awesome. But I don't need it that often right now. Maybe I'll move it to a separate hotkey when I'll need it. (Our names are so hilariously simular, I wonder if I looked at yours when I was choosing mine). Commented Dec 2, 2015 at 16:42
  • And I want vim and less to behave the same, if possible. Less uses a single g. Commented Dec 2, 2015 at 16:44
  • 3
    I probably use gv about every 90 seconds or so Commented Dec 2, 2015 at 17:17
  • 1
    There are also some plugins whose default mappings starts with g, such as gc in commentary. You should also consider that you will run out of keys if you continue using Vim for a long time, and that it takes some time/effort to train your muscle memory after you get used to a given mapping.
    – mMontu
    Commented Dec 2, 2015 at 18:34

2 Answers 2


Assuming you have a newer version of Vim (7.3.1261+) you can use <nowait>

nnoremap <nowait> g gg

Although, I can not stress the usefulness of some of the g mappings. Here is a short list of useful g mappings:

  • gE - backwards end of word motion
  • g_ - to the last non-blank character of a line
  • gt & gT - tab navigation
  • g, & g; - back and forth through the change list
  • gu & gU - case changing
  • gn - visually select current pattern
  • gv - reselect previous visual selection
  • gi - start insert mode in the same position Insert mode was last stopped
  • gf - go to file under cursor (My personal favorite)

See :h g for a list of all g mappings.

Personally I would just learn to use gg as it is a good habit and less is not known to be a good Vi/Vim emulator.

For more help see:

:h g
:h :map-nowait
  • 10
    gi is also pretty fantastic (enter insert mode where you previously left it). I use it all the time when I'm in the middle of typing a line of code and I have to go check something elsewhere in the file.
    – Doorknob
    Commented Dec 2, 2015 at 20:58
  • 1
    Yep. This is like people who map w to :w<CR> and q to :qall<CR> because it's "faster." You're just robbing yourself of the benefits of vim.
    – wchargin
    Commented Dec 3, 2015 at 1:32
  • @WChargin oh, so I'm not the first one. Do you know more about this kind of remaps, can you redirect me to those people? Commented Dec 3, 2015 at 12:22
  • 2
    @PeretFinctor Not sure whether you're joking—my point is that these kinds of remaps are very bad ideas. People who do this are just trying to use vim as a run-of-the-mill editor; w, q, and g all offer extremely extensive functionality that you should be using frequently while editing, but which you are suppressing to shave off fractions of a second when you save. I don't know about you, but I save much less frequently than I move forward a word!
    – wchargin
    Commented Dec 3, 2015 at 19:33
  • 1
    @PeretFinctor: Why don't you use w / W and b / B for word-forward and word-backward, the way Vim provides out-of-the-box? -- You see the pattern here? You try to wrestle with Vim. Move with it, use the things it provides as they are provided. It will be easier that way, and more beneficial for your workflow in the long run.
    – DevSolar
    Commented Dec 4, 2015 at 9:43

Just to chime in, if you really really want a single key - you can still use ... another one (i.e. a key that you don't need that much)! In this way you can leave the useful g prefix alone.

For example, you can "overload" 0 to toggle between 0 and ^ functionality, when repeatedly pressed, and free ^ instead for your usage (since it's an intuitive go up character).

I'm sure this is not perfect, but here's a possible quick-n-dirty proof of concept:

function! ToStartOrNonBlankToggle(mode)
    if (a:mode == 'x')
        normal! gv
    let sp = col('.')
    normal! ^
    let ep = col('.')
    if (sp == ep)
        normal! 0

nnoremap <silent> 0 :<c-u>call ToStartOrNonBlankToggle('n')<cr>
onoremap <silent> 0 :<c-u>call ToStartOrNonBlankToggle('o')<cr>
xnoremap <silent> 0 :<c-u>call ToStartOrNonBlankToggle('x')<cr>
noremap <silent> ^ gg

The above still allows using 0 as motion, and also from visual mode. On an indented line, y0 would now copy from cursor position to the first non-blank character. If you want to copy to the start column instead, you'll have to go visual: v00y

You can now also use 13^ to go to line 13.

  • 1
    That's actually a really good idea, thank you! Commented Dec 2, 2015 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.