Tuesday, March 23, 2021

Re: How to specific the line to go to from the command line?

On Wed, Mar 24, 2021 at 2:02 AM 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
>
> jump to line 23 in command mode:
> 23G
> 23gg
>
> jump to line 23 in command mode:
> :23

Yes, and as icing on the cake, a variation on this one: how to go to a
specific line and column:

" Go to line and column
function GoTo(line, column)
exe min([line("$"), a:line]) "| normal" a:column . "|"
endfunction

see
:help [range]
" a naked range goes to the line(s) mentioned
:help bar
" to go to a certain column
:help min()
" this function takes only a List or a Dictionary as argument

>
> turn line numbering on:
> :set nu
>
> see also:
> :help G
> :help gg
> :help range
> :help 'nu'
> :help +cmd
>
> Sven
>
> --
> --
> 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/20210324010250.7f2354bqmwsbixhl%40guckes.net.

--
--
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/CAJkCKXtZOyk9FOh6XedmFibAd%3DrCgfvHvAMrbP7crwc21-NF5A%40mail.gmail.com.

No comments: