Sven Guckes <guckes@guckes.net> wrote:
> * Peng Yu <pengyu.ut@gmail.com> [2021-03-24 01:51]:
>> I want to specify the line number to go to at the command line.
>> Could anybody let me know how to do it with vim? Thanks.
>
> how to go to line #23:
>
> jump to line 23 on startup:
> vim +23 filename
That's a good answer. The more modern version is to use -c like this:
vim -c :23 filename
Up to ten -c commands can be given, each with an ex mode command. Note
it may need quotes from the shell:
vim -c ':normal 23G' filename
I have a script that I use where I consider the filename to be sensitive
and I don't want it to appear in `ps` output. To invoke vim to edit that
file from script I use a temporary tags file. One could (but probably
would find it too cumbersome) use a method like that to go to line 23.
Here's the bit of sh script I use:
case "$mode" in
# ...
edit) tmp=tags
printf "main\t%s\t1\n" "$name" > $tmp
vim -t main
rc=$?
rm $tmp
exit $rc
;;
# ...
esac
In the 'tags' file I create, the three columns are tagname, filename,
and line number. (In typical 'tags' files the third column is a search
pattern, not a line number. Typically they also have multiple lines with
separate entries.) I then invoke vim with the tag name.
I bring it up in case this isn't going to be cumbersome and might be
something that helps your use case:
vim -c ':set tags=/some/shared/tags/file' -t tagname
Elijah
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4F5Pkq3pj8zfYm%40panix5.panix.com.
No comments:
Post a Comment