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.
The Vim goto line number command One can use the G letter. For example, press [ESC] key and type 10G (Shift-g) goto line number 10.
To do this, press Esc , type the line number, and then press Shift-g . If you press Esc and then Shift-g without specifying a line number, it will take you to the last line in the file.
You could issue zt
after opening the file, so something like: vim +500 filename -c 'normal zt'
.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With