Thursday, October 24, 2013

Re: :buffer command, #, $


On Oct 25, 2013 12:15 AM, "David Fishburn" <dfishburn.vim@gmail.com> wrote:
>
> Vim 7.4.52
>
> I frequently use the :buffer command to change buffers.
>
> The ":buffer partial_name" is really handy.
>
> But if I know the buffer I will often simply use:
> :1b
> :5b
>
> That got me thinking, I didn't know the buffer number, but it was the last buffer I opened.  So I tried:
> :$b
> E86: Buffer 48 does not exist
>
> :ls!
>   1  h   "\Training_1_14\Exercise_1_SimpleForm.html" line 5
>   2  h   "\Training_1_14\Exercise_0_setup.html" line 13
>   3 %a   "test.html"                    line 8
>   4  h   "DataBind.html"                line 9
>   5  h-  "[BufExplorer]"                line 7
>   6 #h   "~\ProgramFiles32\Apache2.2\conf\httpd.conf" line 626
>   7  h   "\Training_1_14\Exercise_2_MultipleAreas.html" line 5
>   8u h-  "help.txt"                     line 0
>   9  h   "\Training_1_14\Exercise_3_CoreFunctions.html" line 5
>  10u a-  "windows.txt"                  line 0
>
> Strange how 48 came along.
>
> httpd.conf" 691 lines --91%--
> :$b
> E86: Buffer 691 does not exist
>
> :#b
> E488: Trailing characters
> :^b
> E492: Not an editor command: ^b
>
>
> Most likely I have hit a bug here, given the output, the buffer number and the similarity it has to previous data displayed.
>
> Just a simple question, does it make sense to expect the usual buffer arguments to work for :buffer?

:buffer # works.

:buffer $ does not, but it may be good to make it work.

Reverse (:#buffer and :$buffer) should not work. VimL syntax is already far too complicated for the purpose it is used. Handling # or $ specially for a :buffer command will make it even more complicated.

Note: everything that goes before the command is range. Range is transformed into line numbers before command is processed. Thus it does not receive information about an exact string that expanded into specific line number.

It may be possible to workaround without complicating commands parsing by saving information about atoms though, but I would not welcome a hack that leaks information from one level of processing to the other.

> The same ones accepted for bufnr()?
> :echo bufnr("$")
> 13
> :echo bufnr("#")
> 6
>
> TIA,
> David
>
>
>
> --
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.

--
--
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.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment