Dan Shumaker
Dan Shumaker

Reputation: 35

Create vim function or map for gggqG

I have this nmap defined:

nmap <leader>fr    :gggqG<CR>

And when I execute it I get an "E492: Not an editor command gggqG" error. However, when I manually execute gggqG it does what it should (basically reformat the current document based on the new tw setting I've setup). I'm starting to want this command more and more and so am looking for a way to simplify the execution of it (I know just typing gggqG is not hard). Does anyone know how I can I define this thing (which I guess is not an editor command) as function or map? Many thanks!

Upvotes: 0

Views: 243

Answers (1)

Peter Rincker
Peter Rincker

Reputation: 45107

gggqG is series of normal commands not command-line command.

nmap <leader>fr gggqG

You should also probably prevent recursive mappings and use nnoremap.

nnoremap <leader>fr gggqG

Upvotes: 2

Related Questions