Jeff Pascal
Jeff Pascal

Reputation: 3

VIM mapping an internal command

I can't figure out how to map an internal command in vim. I want to map to the command :Indent, the action g=GG (indenting the whole document) I did this :

:command Indent execute "g=GG"

And it doesn't seem to work. I successfully mapped

 :command Java execute ":!javac *.java; echo ' **** done **** ' " 

but how do i make it compile only the file that i am working on.

Upvotes: 0

Views: 72

Answers (2)

Luc Hermitte
Luc Hermitte

Reputation: 32926

I don't understand the need either. Still, if you want a command, at least let's have it support ranges:

:command! -range=% -nargs=0 Indent <line1>,<line2>normal! == 

Upvotes: 0

romainl
romainl

Reputation: 196466

gg=G is a normal mode command. You need to use :normal, here:

:command! Indent normal! gg=G

But… :Indent<CR> is much longer than gg=G so I'm not sure that's a good idea.

Upvotes: 1

Related Questions