How can I open vim with a particular line number at the top?

浪子不回头ぞ 提交于 2019-11-29 00:18:40

问题


I know it is possible to have vim open a file at particular line number using this syntax:

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.


回答1:


You could issue zt after opening the file, so something like: vim +500 filename -c 'normal zt'.




回答2:


As an alternative (because I ended up here searching for it), if you want to have the syntax vim <filename>:<linenumber>, eg vim test.rb:45, you can use vim-fetch with Vundle:

Plugin 'kopischke/vim-fetch'



回答3:


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



来源:https://stackoverflow.com/questions/10392424/how-can-i-open-vim-with-a-particular-line-number-at-the-top

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!