I have two windows opened in the same terminal. These are actual vim windows within the same vim instance. The first window is a .py file which has many options set by default, plus additional options that I've set manually. The second window was opened using ctrl-w n which doesn't carry any of the settings from the original window with it. Is there a way to transfer the settings between windows?

In case it makes a difference, this is my version info:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 15 2020 06:40:31)
Included patches: 1-2269

  • You could in theory write a loop to copy all options between two windows. Simpler is to create a script that sets the options and arrange for it to run for relevant files (typically, via an ftplugin or autocommand).
    – D. Ben Knoble
    Commented Feb 2, 2023 at 20:52
  • I vote to put the relevant options in rc via autocommand.
    – gildux
    Commented Feb 3, 2023 at 1:45

2 Answers 2


An option can be buffer-local, window-local, or global.

Global options are, well… global, so they are valid globally unless overridden localy.

Window-local options only have effect in the current window and any new window split from it. <C-w>n splits the current window so all window-local options set in the current window are carried over to the new window.

Buffer-local options only apply to the current buffer.

If the options you set in the current window don't carry over to the new window, it might be because…

  • Those options are not window-local but buffer-local, so there is no reason to expect them to be carried over to the new window.
  • Some autocommand may reset those options for some reason or another.

Without knowing what exact options you have set, I would put my money on the first reason.


In continuation of Romain's answer with whom I agree on the analysis of the issue at hand.

Expecting the global options are already carried over by nature, that window-local options should be carried over automatically when spawning a new window. What's left are the buffer-local options.

IMO, if you want to copy options related to Python buffer, the best is quite certainly to set the filetype of the new buffer to ... python

set ft=python

But still, a few options will be left out:

  • the ones you have set manually (IMO, this practice is best avoided. Prefer automated way to set options)
  • the ones that may come from a plugin emulating local .vimrc support, or any kind of projects. Usually these plugins are activated when the name of the new buffer matches a given pattern. The new window has no associated name. A workaround would be: :vnew %:p:h/new-dummy-name.py. Just don't save the new buffer...

Otherwise, while it's IMO the wrong approach to the problem, it's possible to request:

  • all window-local options (from the current window) with getwinvar('%', '&')
  • all buffer-local options (from the current buffer) with getbufvar('%', '&')

Then, you'll need to iterate on the resulting dictionary and call setwinvar/setbufvar of each dictionary item. Dirty, and faster, one-liners are possible with map()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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