Comments (7)
You can hit o on a file to open it in a new buffer, or t to open it into a new tab. Other operations are not yet supported but I intend to add them.
Switching buffers does work – it’s what readdir does when you try to open an already-open file. But I found it rather disorienting for directories, because your navigation actions suddenly affect a different directory browser than the one you started with. It would only make sense if you could never change directory within a browser but only open directories, as new buffers. That would make some amount of sense, even… but navigating around your filesystem would quickly accumulate lots of open directory buffers. Dunno if that would really be usable.
from vim-buftabline.
It uses the buffer number, not the buffer name. So I have no idea how this situation can happen.
What does :echo buftabline#user_buffers()
say? And :echo winbufnr(0)
when you’re in the netrw buffer?
from vim-buftabline.
:echo buftabline#user_buffers()
shows [1, 2, 3, 4]
:echo winbufnr(0)
shows 5
from vim-buftabline.
Ohhh, I think I remember now… this is one of these bizarro aspects of netrw. When you open a directory, netrw creates an unlisted unnamed alternative buffer for it and renders the directory into that buffer, and then (if I still have the details right) intercepts switches into the regular (and named) buffer and flips you over to the rendered version in the alternative buffer. This is not something that can be handled without specific support for netrw… and I think I didn’t find a way to detect it reliably at the time (my memory is really hazy at this point…).
I vaguely remember this being among the things that drove me to write readdir (“gee, this has to be doable in a less crazy way”).
Edit: jinx…
from vim-buftabline.
Okay, that would make sense, so netrw is in buffer 4 but is randomly also working in buffer 5 somehow?
If you're saying the easiest way to fix this is to use readdir, then fair enough, I'll try it out!
from vim-buftabline.
Well buffer 4 has the directory name but there is nothing in it. And buffer 5 has no name and is not listed but has the directory contents in it. And when you switch to buffer 4, netrw forces you into buffer 5.
I must admit that after having written readdir and run into the same design issues, I can now appreciate why netrw chose this design. I addressed those issues by modifying the buffer name instead, but that creates a variety of other design problems that I then had to work around. I’m not wild about either design.
The fundamental problem is that in Vim, no two buffers can have the same name. So if you render a directory into the buffer directly named after the directory, you cannot have two directory browser buffers showing the same directory. E.g. if you are browsing your home directory in one buffer and ~/.vim/
in the other, you cannot go up one directory in the ~/.vim/
buffer because you already have ~/
open in another buffer.
In readdir I reacted to this by setting buftype
to nofile
to divorce the buffer name from the filesystem, and then adding a unique ID to it. That way multiple readdir buffers can never have the same name even when they’re showing the same directory. But then this has to be undone to open a file, and also, changing the name of a buffer interacts a little weirdly with later opening a file into that same buffer, so I had to find a workaround for that, etc etc.
In netrw they solved all this by doing this alternative unlisted buffer dance instead. In some ways this is less crazy – using multiple buffers isolates the state of each of them, so it’s simpler and more robust compared to readdir, which has to carefully track each bit of buffer state that it relies on. But the netrw bodge is also more visible to the user.
Both approaches suck in different ways. But under Vim’s constraint that buffer names must be unique, I can’t think of any better alternative.
from vim-buftabline.
Hmm, could you just switch buffers when the user tries to cd into a directory that is already open in another buffer? If I have Buffer 1 open at ~
, and Buffer 2 open at ~/.vim
, and I try to open ..
in Buffer 2, you could just leave Buffer 2 as is and switch me into Buffer 1. Or would that not work?
Also, in readdir
is there a way to open a file without closing the directory buffer? Put another way, is there a way to open multiple files from a single readdir buffer? I was thinking something like <S-Enter>
.
from vim-buftabline.
Related Issues (20)
- Reorder buffer tabs in MRU order? HOT 2
- Question regarding global manul installation HOT 1
- buftabline and goyo don't work together HOT 5
- NeoVim external GUI tabline needs to be disabled separately HOT 4
- Splits: non-focused split more highlighted than focused one HOT 4
- Highlight name only of the buffer with cursor in it? HOT 3
- tab highlight color override bug — coloring over underline HOT 4
- Is this project dead HOT 1
- Order options for Buftabline HOT 4
- g:buftabline_show = 1 doesn't work when opening quickfix window HOT 4
- Crash with g:buftabline_show = 1 HOT 1
- Is there a way not have gap between buftabline and window top? HOT 1
- Buffers with "%" in filename HOT 1
- opening a vim terminal buffer breaks tab switching HOT 2
- Don't show vim terminal as buffer tab HOT 5
- Buftabline is not clickable on vim? HOT 1
- Improve the documentation for colorscheme customization HOT 6
- Fork permission HOT 2
- What's the colorscheme or color configs for the image in README doc? HOT 4
- I have buftabline on two different computers, one asked me to save files when I switch buffers the other does not HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-buftabline.