vimr icon indicating copy to clipboard operation
vimr copied to clipboard

Open files in buffers rather than tabs

Open gibfahn opened this issue 7 years ago • 13 comments

I use ap/vim-buftabline and have Tab and ShiftTab mapped to :bn and :bp, so I don't really ever have a use for tabs. It would be great if there was an option to have

vimr a b c
vimr 1 2 3

open the 6 files in buffers rather than tabs, so I can Tab my way through them. I understand from vimr -h that By default all files are open in tabs, and I'd be happy for an option somewhere that disables that. If there's already an option somewhere I missed then sorry in advance!

gibfahn avatar Sep 03 '17 00:09 gibfahn

What you probably can do is the following (please correct me if I'm wrong):

$ vimr --nvim SOME_OPTIONS

where SOME_OPTIONS would contain all arguments you would use to achieve what you want using nvim in terminal. So if

$ nvim --some --option file1 file2 file3

would do what you want in terminal, you can use

$ vimr --nvim --some --option file1 file2 file3

Would this help?

qvacua avatar Sep 08 '17 15:09 qvacua

@qvacua I think (I'm not a super-vim-expert :grin: ) that I won't be able to do that, the problem is that I want to do the default, which would be:

nvim a b c

but vimr automatically converts that to:

nvim -p a b c

which makes everything open in new tabs rather than buffers. I'm not aware of a command to counteract that setting (which from vimr -h I guess is set in vimr's source code).

gibfahn avatar Sep 08 '17 21:09 gibfahn

If you want to do nvim a b c, then try

$ vimr --nvim a b c

(make sure you have the newest version of the command line tool vimr 😀)

qvacua avatar Sep 09 '17 06:09 qvacua

@qvacua ah I see, so that half-works.

It opens the files in buffers not tabs, but when you open more tabs it opens another instance of vimr, rather than adding to the existing one.

Is there an option to preserve the "add to existing vimr window" default, but also have buffers as well?

vimr --nvim a b c
vimr --nvim d e f
image

gibfahn avatar Sep 09 '17 10:09 gibfahn

+1 for this. I just got bitten by it today. It seems better to use the nvim defaults, but I would be OK with a command-line option as well.

mvanier avatar Jan 29 '18 21:01 mvanier

As a workaround, autocmd VimEnter * silent! tabonly can be used to prevent vim from being started with tabs.

ptzz avatar Apr 23 '18 04:04 ptzz

@ptzz that option works for me in neovim, but not in Vimr. Not sure why (or if I'm doing something wrong).

gibfahn avatar Apr 25 '18 15:04 gibfahn

+1 This is currently the last remaining thing preventing me to move entirely over to VimR for my OSX NeoVim needs.

andrimarjonsson avatar Aug 04 '18 15:08 andrimarjonsson

+1 This would be awesome!

ljohnston avatar Apr 22 '20 00:04 ljohnston

Hi, I just started using vimR. Seems like it might be just what I want, once I get inevitable configuration issues worked out. Not vimr's fault. So thank you. I wanted to put in a few more remarks on this issue.

In my case, I don't ever want files to open in separate tabs. Given that vim, nvim, and MacVim GUI don't do this by default, it would be nice if there were an obvious way to turn the behavior off (or even if it defaulted to off). --nvim does work, that's a solution, but it was difficult to find it in this issue. (I'm not sure what I am missing if "--cur-env, --line, --dry-run and --wait" aren't passed to nvim. But I don't know what those do--I don't use them--so I guess it doesn't matter.)

Would it be possible to add a section to the documentation page about how to configure tabs on/off?

A related issue: It's OK to have one tab left, but for me it's kind of a wasted line of space. Turning off "Use custom tab implementation" gets rid of it, but causes the vim status bar to be misplaced until I resize the window with the mouse.

(By the way, I'm happy that vimr opens a new gui window each time it's run from the command line.)

Thanks!

mars0i avatar Mar 30 '22 04:03 mars0i

If you're looking to open a new buffer (versus a new tab) from inside a neovim terminal:

  1. Install https://github.com/mhinz/neovim-remote.
  2. Add the following to your .bashrc:
# Open new files in current neovim instance, if available.
if [ -n "$NVIM_LISTEN_ADDRESS" ]; then
  alias vimr='nvr'
fi

Then vimr will open files in a new buffer inside of the current vimr instance.

philipn avatar Apr 02 '22 08:04 philipn

Has anyone gotten this to work?

  • vimr --nvim foo.txt opens files in a new window, not in the same tab of the current window
  • autocmd VimEnter * silent! tabonly doesn't seem to change the behavior at all

jstevej avatar Jul 25 '23 00:07 jstevej

This worked for me:

autocmd TabEnter * silent! tabclose

jstevej avatar Jul 25 '23 12:07 jstevej