[英]Vim: Pascal autoindent
I have a problem with Pascal auto-indentation in Vim. 我在Vim中有Pascal自动缩进的问题。
begin
writeln('Hello World');
end.
Vim do not indent end.
Vim不缩进
end.
. 。 However if there is
end;
但是如果有
end;
it is indented properly. 正确缩进。
When I perform gg=G
whole code is indented properly. 当我执行
gg=G
整个代码会正确缩进。 Is there a way to make Vim to use command like gg=G
"on the run"? 有没有办法让Vim在运行时使用
gg=G
类的命令?
Yeah seems to be an oversight. 是的,这似乎是一个疏忽。 (You should go file a bug report, you can find the maintainer of the script at the top of file located at
$VIMRUNTIME/indent/pascal.vim
) (您应该提交一个错误报告,您可以在
$VIMRUNTIME/indent/pascal.vim
的文件顶部找到脚本的$VIMRUNTIME/indent/pascal.vim
)
You just need to append =end.
您只需要附加
=end.
to indentkeys
. indentkeys
。 indentkeys
controls when vim should try and reindent the current line. indentkeys
控制vim应何时尝试重新缩进当前行。 To do this add setlocal indentkeys+==end.
为此,请添加
setlocal indentkeys+==end.
to the file ~/.vim/after/indent/pascal.vim
(You will need to create the file and the directories if they do not exist) 到文件
~/.vim/after/indent/pascal.vim
(如果文件和目录不存在,则需要创建它们)
This file will get sourced after the normal indent script gets sourced which is what you want. 在获取普通缩进脚本后,将获取该文件。
Take a look at :h indentkeys
and :h after
看看
:h indentkeys
和:h after
Side note: gg=G
reindents the whole file but it is not a single command. 旁注:
gg=G
重新缩进整个文件,但这不是单个命令。 It is actually two different ones. 实际上是两个不同的。
gg
which is move to the top of the file and ={motion}
which is reindent from the current line to the end of the motion. gg
(移至文件顶部)和={motion}
(从当前行重新缩进至运动结尾)。 The {motion}
in this case to go to the end of the file. 在这种情况下,
{motion}
转到文件末尾。 So we reindent the whole file. 因此,我们重新缩进整个文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.