0

Currently I'm using this to open a file in an existing vim instance.

gvim --remote-silent some_file.txt

While it opens the file as expected, it sometimes splits the window.

I'm not sure what logic it uses, but I'd like to be able to tell it never to create a new split-window for the new buffer since it means I need to manually delete the new window - which gets annoying.

  • Do you have :set hidden in your vimrc? – romainl Nov 5 '16 at 9:04
  • No, but I have: set nohidden. – ideasman42 Nov 5 '16 at 9:26
  • Well, your "problem" is a direct consequence of :set nohidden. – romainl Nov 5 '16 at 16:07
  • I've removed set nohidden and still had this problem occur. Perhaps nerdtree or some other plugin is messing with my config. (though I don't use so many plugins) – ideasman42 Nov 7 '16 at 12:41
1

When you use Vim's --remote options, it constructs a :drop command.

If the specified file is not already open in an existing window, it will be opened in the current window, unless the file currently in that window cannot be abandoned. (i.e. if the current file is modified and you have both hidden and autowrite options switched off.) In that case, the window is split instead.

Note however, that at some point in the past there was a bug with this behaviour, which was fixed in version 6.1.173:

When using remote control to edit a position in a file and this file is the current buffer and it's modified, the window is split and the ":drop" command fails.

0

I may be off from your actual purpose and you may already know what I suggest here, but how about opening the file in a new tab from within vim?

:tabnew some_file.txt

If some_file.txt exists it will open it in a new tab, if not it will create a new empty file. You navigate from tab to tab with gt (move one tab on the right) and gT (move the other way).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.