我正在尝试在 csv 文件上运行一系列命令;做一些替换,改变一些东西。我在 vim 中打开文件并使用
so! filewithcommands
。但是 gg
永远不会到达文件顶部,总是到达第二个位置。
samplefile.csv 的内容:
sometext;morechars
nextline;withsomemoredata
areyou;gettingthepoint
带有命令的文件内容:
gg
当我打开
vim --clean
并运行 :so! filewithcommands
时,光标会由于某种原因跳转到 second 行。我已经尝试过:0
但同样的事情发生了。使用 Vim v 9.0.2121 运行 Ubuntu。
filewithcommands
中的命令应该是 Ex 命令,因此 gg
(普通模式命令)与此处无关。事实上,这就是 Vim 想要告诉你的:
Error detected while processing /path/to/filewithcommands:
line 1:
E492: Not an editor command: gg
更多信息由
:help 492
提供:
Not an editor command ~
You tried to execute a command that is neither an Ex command nor
a user-defined command.
错误消息是一件好事,跳过它们绝不是一个好主意。举个例子:
gg
是错误的,无论如何都不会达到你的期望。添加 !
来跳过错误消息不会使 gg
神奇地做它不能做的事情。它只会剥夺 you 了解问题并解决问题的机会。
将光标移动到缓冲区顶部的 Ex 命令是:
:1
所以这就是你应该放入你的
filewithcommands
:
1
(在这种情况下,
:
不是必需的)