Questions tagged [buffers]

The representation of a file loaded into memory. Edits are performed on buffers.

Filter by
Sorted by
Tagged with
6
votes
1answer
114 views

How can I view the name of the swapfile being used for the current buffer?

Let's say I recovered a bunch of swapfiles in quick succession: gvim -r .swv gvim -r .swu gvim -r .swt And then cycled through them all a few times before finding that one of them was nonsense. I ...
6
votes
2answers
968 views

Limit buffer list to current tab

Is there a way to list the buffers specific to the tab that is open currently in vim or macvim?
6
votes
1answer
927 views

Why can't I execute write command on all buffers with :bufdo?

I have multiple buffers open, some currently visible, some not. I know I can write all of them with :wa. However, I am curious, why :bufdo w does not work. When I try it in a buffer with unsaved ...
6
votes
1answer
109 views

Automatic name for new files

For new files, Sublime Text changes the file name to the first line of the file: Is it possible to achieve this on Vim?
6
votes
3answers
4k views

make nerdtree buffer consistent

I like how nerdtree looks as a side-drawer. but if I close current buffer using :bd nerdtree will become a fullscreen buffer and all new buffers will simply take full screen, nerdtree won't toggle ...
6
votes
1answer
399 views

Fixing lag due to vim-troll-stopper plugin

I've recently installed a plugin called vim-troll-stopper. Some unicode characters are drawn exactly the same but have different meanings. I think they are called homoglyphs. Some programmers may use ...
5
votes
3answers
530 views

Is there a trick to set 'ignorecase' locally

ignorecase is a global option, so it's not possible to locally set ic :setlocal ic This is a bit unfortunate, since I work on buffers in which I need to search case insensitively and other buffers ...
5
votes
4answers
2k views

How to shorten the result of `ls` to get only the file name and not the whole path?

I've been using Gvim for a while, but lately stopped using GUI options and went to just commands. :ls is used all the time, but I have a huge project and it is hard to see the file name quickly in the ...
5
votes
2answers
898 views

Which buffer quickfix file is opened in?

One thing that drives me crazy is unpredictable quickfix behaviour. Say I am editing a file, then I split the window and would like to find something and open in that buffer. I use :Ag whatever to ...
5
votes
2answers
290 views

Is there a direct way to select the buffer displayed in a non-active window?

I usually have two windows open, one in which I'm working and one in which I'm viewing some information (compiler messages, relevant library headers, etc. etc.). Now, it's easy to switch the buffer on ...
5
votes
2answers
237 views

Closing all buffers that represent .js files?

Can I close all buffers by regex, for instance all buffers that hold open .js files? Effectively what I want is :bd *.js But even with ! if more than one .js is open I get, E93: More than one ...
5
votes
2answers
163 views

Put current mappings into a buffer

To take a look at the mappings in my current session I fired: :map to list all current mappings. The output opens in some sort of read only awkward window. It's only possible to scroll. It's not ...
5
votes
2answers
156 views

How to replace buffer with a search range selection?

I'd like to replace the entire buffer (file) with the current search range selection: :/pattern1/;,/pattern2/p How this can be achieved?
5
votes
1answer
835 views

Spread already open files into split view

Suppose I open multiple files in vim like this: vim a.cc b.cc x.cc vim will open all files, but show only one at a time, the rest being accessible using the :next command. After having these files ...
5
votes
1answer
3k views

Is it possible to obtain the displayable area, width and height of current buffer in Vim?

I know Vim provides functions to display window's dimensions. But does it also provide ways for me to know current buffer/split's dimensions? Like how many lines and columns in displable area? ...
5
votes
1answer
5k views

Working with error lists while compiling

When I try to get a program to compile, I use the following process: :sh to open a shell make scroll up to see the compilation errors exit to get back to vim fix errors that I remember (usually 2 or ...
5
votes
2answers
887 views

How could I maintain split layout when deleting buffers?

I opened 5 buffers and in one of them I use the command :vs to split the current buffer screen into two. When I use the command <leader>d to close one of the splitted buffers, the consequence is ...
5
votes
1answer
1k views

Disable swap file for large files [duplicate]

I normally like to keep swap files on, but if I am editing huge log files I usually don't want them. Since I am just viewing the files in vim, it is unnecessary to have a swap file. I could just run ...
5
votes
1answer
2k views

In an autocmd what's the use of the BufRead event?

I'm trying to learn a bit of vimscript and currently reading the 12th chapter of Learn Vimscript the Hard Way. In this page, the author says : A common idiom in Vim scripting is to pair the ...
5
votes
2answers
614 views

Why does gx call curl when the cursor is on a URL with trailing slash?

When my cursor is on a URL that ends with a trailing slash, for example : http://www.google.com/ ... if I type gx to open the link in my browser, curl is also called to download the webpage and the ...
4
votes
2answers
1k views

Changing between the active buffer and the alternate buffer

I'm trying to change between the active buffer and the alternate buffer with the command Ctrl + ^ as this video explains. However, nothing happens. I'm using a Spanish keyboard and to press the ^ ...
4
votes
2answers
898 views

Buffers comand to show full path and filename

Using :buffers results :buffers 1 %a "my-jspage.md" line 11 Are there any options so :buffers will list full path and filename? E.g.: :buffers 1 %a "d:\projects\self-org\my-...
4
votes
3answers
769 views

How to list open buffers simplified

I'd like to use ls command to show opened buffers. I'd like to make the output of this command as simple as possible. I'd like to see only the buffers' names, numbers and status (#,%,+,..). I don't ...
4
votes
2answers
1k views

What types of buffers are there?

Many answers make reference to a "paste buffer" or a "search buffer". Can someone provide a quick primer on what types of buffer there are? Are they interchangeable? Or is it something different?
4
votes
1answer
262 views

Switch to viewport by name?

Typing :buffers gives a list of loaded buffers. Can I switch to a viewport that views one of those buffers by name? I know that :buffer NAME will load the named buffer in the current viewport. But I ...
4
votes
2answers
337 views

How to escape from file browsing mode?

I just found out that we can use :e . to enter the browsing mode and then can choose file what we like. But I don't know how to get back to already opened file without choosing it again. I tried &...
4
votes
1answer
227 views

How to navigate vim buffers using quickfix list?

I am trying to come up with a way to populate the vim quickfix window with the output from :ls I tried some variants like cexpr ":execute ls" but it doesn't work. Can someone please help me ...
4
votes
1answer
232 views

Skip the quickfix list when buffer switching using :bn

Often when editing LaTeX files, you are constantly switching between your .tex, .sty and .bib files which are often in their own buffer. To navigate between those, I use the :bn and :bp commands ...
4
votes
1answer
553 views

Block-less argdo on many files?

I am running a simple substitution on many files with :argdo %s/foo/\rfoo/ge | update. Vim shows the progress through files (number of substitutions in file) and when the screen fills up it blocks ...
4
votes
1answer
740 views

Why are my buffer numbers so high?

When I type :ls, I get a list of buffers with non-sequential, high numbers (I didn't open 800 files): :ls! 1 "b(...)" line 67 2 # "b(...)" line 90 3 "b(...)" line 50 4 "b(......
4
votes
2answers
1k views

When using bash or another shell from a buffer, how do I modify text?

Inside vim, I often use conque plugin, so I can run a bash shell inside a vim buffer. I also may try out VimShell soon. In conque, lets say I start typing some bash command, and before I enter it, I ...
4
votes
2answers
491 views

How can I ensure Vim doesn't quit entirely when the last window is closed, unless it's empty?

I'd like to mimic the behaviour of i.e. TextMate and VScode and friends, in a GUI-vim: "closing" the last actual-content-window simply leaves me with an empty Vim window, and then "closing" that is ...
4
votes
2answers
2k views

How do I make netrw behave with respects to cycling through buffers with :bprevious/:bnext

I have my vim setup according to "Solution #1: Replicating Tabs with Buffers" on this site buffers-vs-tabs with the vim-airline plugin. If I open numerous files in buffer 'tabs' :bprevious/:bnext ...
4
votes
1answer
154 views

Swap choices: how can I "skip" instead of "quit" or "abort"?

Swap file ".file.swp" already exists! [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: I usually see this message when I accidentally :edit the wrong file, i.e., one which I'm already ...
4
votes
1answer
1k views

How can I get a window to close automatically when all other windows have closed?

I'm writing a script that creates a window that I'd like to be completely transient, like a help window. Specifically, if the user closes every window but this one, I want Vim to quit. (In the same ...
4
votes
1answer
2k views

How does vimscript know which buffer these buffer-local variables use?

Consider the following vimscript: function! DecideWhetherToStrip() let l:search = @/ " Check if a file being opened has trailing spaces in the first place. let b:dostrip = !search('\s\+$',...
4
votes
3answers
335 views

edit many files in one buffer

I have enjoyed coding not too large projects in one single file. This way I can press * on an identifier and find it without having to hop across buffers. But naturally this doesn't scale and at some ...
4
votes
1answer
907 views

How to see if Vim has a file opened or not, or has a buffer open

Sometimes I want to open vim in preparation of opening a file in the directory tree. So i start it without a file: vim Then I use a map to open NERDTree: :NERDTreeFind<CR> This fails with ...
4
votes
2answers
828 views

vim sometimes displays full path of file instead of just the filename?

This may seem a little nit-picky, but I like using the wildmenu to switch between buffers: I do :b and then hit tab until I get to the file I want. The problem is that sometimes, vim shows the entire ...
4
votes
1answer
821 views

Strange behavior between autochdir and netrw

This has been plaguing me for a while now, but I've only just recently been able to come up with an MCVE. The problem is that when autochdir is on and I use :Explore to open netrw sometimes it will ...
4
votes
1answer
2k views

How to set a local variable for a plugin in a BufNewFile autocmd

I currently have autocmd BufRead *.sage \ set filetype=python | \ let b:syntastic_skip_checks=1 which works as intended (sage files are treated as Python, but with Syntastic disabled)...
4
votes
1answer
149 views

Workflow for editing file in same (deeply nested) directory

I currently use Vim for Java development. I use maven and for a small project I typically begin by running vim . or vim pom.xml from terminal at project root and :argadd **/*.java to add all the ...
4
votes
3answers
362 views

Is it possible switch buffers in order of accessing but not opening?

At first I am going try to explain you "order of opening". For example, if I'll open files in this order: 1_file.c 2_file.c 3_file.c 4_file.c :ls command will give me: :ls 1 "1_file.c" ...
4
votes
2answers
249 views

Open new file while keeping the focus on the the current buffer

It is possible to open a new file with :edit or :tabnew but without jumping to that new buffer ?
4
votes
1answer
57 views

track deletion and insertion of lines

The marks in vim knows the deletion and insertion of lines before it and their positions will keep updated. Is there a way to achieve these pragmatically? I am running an async task which is ...
4
votes
1answer
187 views

Strange interaction of set hidden, shortmess and the status line

My .vimrc contains set hidden set shortmess=fotx I start Vim 7.3 with vim a b I modify a (optional), then I save it and switch to the next file with :wn. Then I use :prev to return to the previous ...
4
votes
1answer
2k views

Buftype=nofile when switching buffers with :Vexplore

When I open up :Vexplore in a split and open a file in it, the file in the other split ends up with buftype=nofile set so I can't write in that file or anything. But the new buffer that was opened ...
4
votes
2answers
693 views

Is there a way to list recent buffer history?

I just started using buffers in Vim and I couldn't figure out how to list recent closed buffers. Is there a simple way (like :ls) to list those? Are they actually stored by Vim? Maybe I'm misusing ...
4
votes
0answers
96 views

Return to previous buffer without going through every jumplist entry [duplicate]

When I've jumped from a buffer to another buffer I use C-o to return and after that I use C-i if I want to jump to that same buffer again. I think this is the common approach. The problem is that this ...
3
votes
2answers
534 views

call function in context of buffer

How can I call a function in vimscript in the context of a specified buffer? For instance, line2byte works for the current buffer. I am implementing a callback, where I receive a buffer number as an ...

1
2
3 4 5
8