Linux 如何在顶部打开带有特定行号的 vim?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10392424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I open vim with a particular line number at the top?
提问by stinkypyper
I know it is possible to have vim open a file at particular line number using this syntax:
我知道可以使用以下语法让 vim 在特定行号处打开文件:
vim +500 filename
However, I would like it to open with the specified line at the top of the editor window, not in the middle.
但是,我希望它以编辑器窗口顶部的指定行打开,而不是在中间。
采纳答案by Cat Plus Plus
You could issue zt
after opening the file, so something like: vim +500 filename -c 'normal zt'
.
您可以zt
在打开文件后发出,例如:vim +500 filename -c 'normal zt'
.
回答by sehe
This should do it:
这应该这样做:
vim +'500|norm! zt' filename
Or you could just start the habit of using zt(top), zz(center), and zb(bottom); In my case, it is so automatic, I wouldn't really require the extra invocation argument
或者你可以开始使用zt(top), zz(center), and zb(bottom)的习惯;就我而言,它是如此自动,我真的不需要额外的调用参数