Friday, October 19, 2012

Re: Regarding NETRW and the buffer list

On Friday, October 19, 2012 6:27:26 PM UTC-7, Tony Mechelynck wrote:
> On 20/10/12 02:13, Ken L wrote:
>
> > Hello everyone,
>
> >
>
> > I'm a Vim new user, so please forgive my ignorance, but when using NETRW, is it possible to prevent it from displaying filepaths in the buffer list (:ls)? My list quickly becomes cluttered with these path names, and I'd rather have it display currently open buffers only.
>
> >
>
> > Thank you,
>
> >
>
> > Ken
>
> >
>
>
>
> There are two commands for this kind of job: :bdelete and :bwipeout
>
> (which can be abbreviated by removing any number of characters from the
>
> end, except the first two after the colon).
>
>
>
> :bdelete keeps the buffer name in memory, but :ls won't show it unless
>
> you use :ls! with exclamation.
>
>
>
> :bwipeout really forgets everything that Vim knew about the buffer.
>
> Including what you would have liked to remember later!
>
>
>
> In no case, however, are buffer numbers reallocated: if you use :bd or
>
> :bw, the corresponding buffer number will be "missing" from the output
>
> of :ls until you quit Vim.
>
>
>
> See:
>
> :help :bd
>
> :help :bw
>
> :help :ls
>
>
>
> The purpose of :ls displaying even buffers not currently shown in a
>
> window is because you may have something important to do about them. For
>
> instance, starting Vim as
>
>
>
> vim file1.txt file2.txt file3.txt
>
>
>
> will start Vim will three files, but only one of them will be displayed
>
> in a window. The other two are available though, and :next will cycle
>
> through them (except that you will have to save a modified file first,
>
> or confirm its discard).
>
>
>
> All those buffers are "open" in a sense, even those that aren't
>
> displayed in a window at the moment. Here is perhaps the place for a
>
> little boilerplate about Vim terminology:
>
>
>
> Vim has one or more buffers. Each buffer usually represents one file,
>
> but it may be a file which doesn't yet exist on disk, or even a file
>
> which will never be written to disk. A buffer can also be empty. It can
>
> even be a placeholder for some data which will be fetched from disk
>
> (from a known disk path) the next time you want it displayed in a window.
>
>
>
> Each buffer is displayed in zero or more windows. A window is a kind of
>
> viewport on a buffer; depending on the respective sizes of both, the
>
> window may contain all or part of the buffer, or even (for a small
>
> buffer) all the buffer with some empty space left over at the bottom.
>
> Editing a file normally consists of making changes to the buffer
>
> displayed in the current window; these changes may then be written to
>
> disk � or discarded.
>
>
>
> Vim has one or more tab pages; one and only one of them is visible at
>
> any time; if there are others, they usually have tab labels near the top
>
> of the Vim screen (in gvim, below the menu and toolbar). Each tab page
>
> contains one or more windows. If there are several windows in a single
>
> tab page, they may be split vertically, horizontally, or in any combination.
>
>
>
> What is called "a window" in Vim language is not the same as what your
>
> OS calls "a window". Every running instance of Vim handles one and only
>
> one "OS window" but there may be any number of "Vim (split) windows" in
>
> it (well, no fewer than one, and the upper limit depends on the
>
> available memory on your computer). (An exception to this may be MacVim:
>
> on the Mac, I think I've heard about the possibility of having a single
>
> running instance of MacVim handle several "windows" in the OS sense, but
>
> I'm not sure of the details � or maybe I misunderstood: I'm on Linux.)
>
>
>
>
>
> See
>
> :help windows.txt
>
> :help tabpage.txt
>
>
>
>
>
> Best regards,
>
> Tony.
>
> --
>
> unix soit qui mal y pense

Hey Tony,

Thanks for the in-depth response! I appreciate it very much.

Yes, I have familiarized myself with the differences between buffers (including hidden), tabs, and windows, and use them quite frequently (well, only hidden buffers and split windows, since I prefer not to use tabs). I've also mapped :bnext and :bprev to tab/shift-tab in normal mode to make cycling through buffers very quick and easy.

Anyway, here's what I do: I almost always use the CtrlP plugin to quickly find my files (I've mapped my most-used directories to it). But I also use NETRW to manually navigate to files located elsewhere. I use :Vexplore! to open up a righthand side vsplit, find my file, and then open it to replace the NETRW window (netrw_browse_split=0). But once I've opened my file, I'd like the filepath to disappear from the buffer list. As I mentioned before, I like to :bprev/:bnext through buffers, but continually coming across leftover directory trees from NETRW is interfering with my rhythm (I always have to stop what I'm doing to type :bd to make them vanish).

Perhaps I'm misunderstanding, but is constantly using :bd/:bw to remove filepaths "normal" procedure when using NETRW? I feel like I'm missing a critical piece of information in understanding how it works.

Cheers,

Ken

--
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

No comments: