I want to be able to open files using the same instance so I added --remote-silent
when opening files. But the first time it loads, Vim will open an empty buffer, then my file. So now I have 2 buffers.
Upon further investigation, I noticed that setting nohidden
will solve this problem. BUT, not only is it against my liking, it will cause the first buffer to have no syntax highlighting.
This doesn't happen without the --remote-silent
option.
Any help appreciated. Thanks!
A buffer is an area of Vim's memory used to hold text read from a file. In addition, an empty buffer with no associated file can be created to allow the entry of text. The :e filename command can edit an existing file or a new file.
Use the ":sbuffer" command passing the name of the buffer or the buffer number. Vim will split open a new window and open the specified buffer in that window. You can enter the buffer number you want to jump/edit and press the Ctrl-W ^ or Ctrl-W Ctrl-^ keys. This will open the specified buffer in a new window.
:wa - save all tabs / unsaved buffers. :xa / :wqa - save all tabs / unsaved buffers and exit Vim.
Doing $ vim --servername FOO --remote[-silent] filename
without an instance already running launches a new instance first then opens the file: it is not like $vim filename
. You have to find a way to completely remove the first empty buffer.
From my limited testing, adding set bufhidden=wipe
to your ~/.vimrc
may solve the problem.
set bufhidden=wipe
, being local to a buffer, is applied only to the first empty buffer and reset afterwards.
See :h bufhidden
.
This will certainly cause some problems when you run Vim normally, though.
edit
Yes, set bufhidden=wipe
causes obvious problems. When launched "normally" (with $vim file1
) the first buffer is wiped when you edit a second file which is not what you want.
A simple check on the name of the buffer resolves that problem:
if bufname('%') == ''
set bufhidden=wipe
endif
Syntax highlighting works in every situation, here. Could you post the content of your ~/.vim/
and ~/.vimrc
somewhere?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With