prompt-toolkit / pyvim

Pure Python Vim clone.
BSD 3-Clause "New" or "Revised" License
2.52k stars 161 forks source link

:b works for buffer, but not :b1 with number #20

Open lunemec opened 9 years ago

lunemec commented 9 years ago

In vim you can use :b1 to go to buff number 1 .. with any number. This does not work in pyvim.

jonathanslenders commented 9 years ago

Thanks for reporting. Normally :b 1 (with a space in between) should already work. I was not aware that it was possible without. I'll fix that as well.

By the way, feel free to keep reporting missing key bindings or commands. Vim has a lot, and implementing all of them is not feasible in the short term. But things that are reported will probably get priority.

lunemec commented 9 years ago

Sure, I'll try to use it tomorrow at work and report what I can find.

jonathanslenders commented 9 years ago

I made "vi" an alias for "pyvim" now. That forced me to use it all day. :) Actually, right now, I'm doing all pyvim development in pyvim itself.

That way, every time I need a missing feature, I want to implement it asap.

lunemec commented 9 years ago

Yes, I completely agree, this is the best way. I'll try to contribute something during the weekend instead of issues alone :)

lunemec commented 9 years ago

I think we should rename :bw to :bd ... from vim's help buffer

:[N]bd[elete][!]            *:bd* *:bdel* *:bdelete* *E516*
:bd[elete][!] [N]
        Unload buffer [N] (default: current buffer) and delete it from
        the buffer list.  If the buffer was changed, this fails,
        unless when [!] is specified, in which case changes are lost.
        The file remains unaffected.  Any windows for this buffer are
        closed.  If buffer [N] is the current buffer, another buffer
        will be displayed instead.  This is the most recent entry in
        the jump list that points into a loaded buffer.
        Actually, the buffer isn't completely deleted, it is removed
        from the buffer list |unlisted-buffer| and option values,
        variables and mappings/abbreviations for the buffer are
        cleared.

:[N]bw[ipeout][!]           *:bw* *:bwipe* *:bwipeout* *E517*
:bw[ipeout][!] {bufname}
:N,Mbw[ipeout][!]
:bw[ipeout][!] N1 N2 ...
        Like |:bdelete|, but really delete the buffer.  Everything
        related to the buffer is lost.  All marks in this buffer
        become invalid, option settings are lost, etc.  Don't use this
        unless you know what you are doing.
lunemec commented 9 years ago

I tried :b N in vim, and it doesn't work at all, I guess it never worked and always was without space :bN

lunemec commented 9 years ago

I added alias to :bw also work with :bd, there is difference between these in vim, but I'm not sure what to make of the explanation from the help page and how it is supposed to work.

https://github.com/jonathanslenders/pyvim/pull/44

lunemec commented 9 years ago

I'm trying to make this work, but from what I've discovered, there would need to be dynamic adding of commands 'b1', 'b2' to the COMMANDS_TO_HANDLERS when adding/deleting buffers. These would need to call function bringing up specific buffer. But what I think would be better is if the command could contain regexp. That way, you could just write into the decorator this:

@cmd('b(%d+)')
def buffer_switch(regexp_groups):
    ...
lunemec commented 9 years ago

https://github.com/jonathanslenders/pyvim/pull/50

lunemec commented 9 years ago

The change in the pull request works OK, but I'd like to see which buffer I'm switching to since the numbering is dynamic (when you close buffer, others after it get its number). I'd like to add the completer so it would display which buffer are you switching to.

Example: You'd write :b1 and this would display either No matches, or what is under buffer number 1. But this cannot happen sooner (right after you write :b) this would disable shortcuts :bn :bp and maybe others.

I'll try to figure out how the completer works and try to add this.