I'm writing a vim function to set hard tabs and refactor indents in a whole file. This is the function:

function RefInd()
    :set tabstop=4 softtabstop=0 noexpandtab shiftwidth=4

And this is the error:

Error executing the function RefInd:
Line 2:
E492: Not an editor command: ^Igg=G
Press ENTER or type command to continue

Any help?

  • 3
    gg=G is a normal mode command. Use normal gg=G.
    – muru
    Commented Mar 23, 2016 at 17:11
  • 4
    @muru You typically want to use normal! to make sure you're not running user-defined mappings. Commented Mar 23, 2016 at 17:13
  • @Carpetsmoker of course! My, bad.
    – muru
    Commented Mar 23, 2016 at 17:14
  • 4
    Take a look at :retab and :retab!.
    – jamessan
    Commented Mar 23, 2016 at 17:50

1 Answer 1


The problem is that gg, = and G are normal mode commands, as opposed to ex commands which are used within a script. Writing normal gg=G should solve your problem.

As @Carpetsmoker has pointed out in his comment, using normal! instead of normal might be prudent to avoid running user-defined mappings by accident.

See also :help :normal.

  • Done. It works. Commented Mar 24, 2016 at 10:07

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.