Vim --remote-silent always opens the [No Name] buffer for the first file

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, and then my file. So now I have 2 buffers.

After further study, I noticed that configuring nohidden will solve this problem. BUT, this is not only to my taste, it will lead to the fact that the first buffer will not be allocated with syntax.

This does not happen without the --remote-silent option.

Any help appreciated. Thanks!

+4
source share
1 answer

Running $ vim --servername FOO --remote[-silent] filename without starting the instance starts a new instance and then opens the file: it does not look like $vim filename . You should find a way to completely remove the first empty buffer.

From my limited testing, adding set bufhidden=wipe to your ~/.vimrc might solve the problem.

set bufhidden=wipe , which is local to the buffer, applies only to the first empty buffer and reset subsequently.

See :h bufhidden .

This will certainly cause some problems if you usually run Vim.

change

Yes, set bufhidden=wipe causes obvious problems. When you start "usually" (with $vim file1 ), the first buffer is erased when you edit the second file that you do not need.

A simple check of the buffer name fixes this problem:

 if bufname('%') == '' set bufhidden=wipe endif 

Syntax highlighting works in any situation here. Could you post the contents of your ~/.vim/ and ~/.vimrc somewhere?

+3
source

Source: https://habr.com/ru/post/1433101/


All Articles