2

我熟悉 = 过滤器。== 键序列缩进当前行,而 gg=G 缩进整个文件。我正在尝试创建一个命令:FixIndentation 以获得类似的效果,以修复整个文件中的缩进。

# vim documentation provides example to map to key 
map <F7> gg=G<C-o><C-o>

# my attempt to map to a command fails
command ReIndent execute "gg=G"
:ReIndent

E492: Not an editor command: gg=G
4

1 回答 1

3

添加正常!告诉它在正常模式下执行它:

command ReIndent execute "normal! gg=G"
于 2020-08-08T12:00:25.757 回答