Auto focus new window (without breaking neotree)

Hi, I would like to move my cursor into the new window when creating a split.
I came across the following Autocommand which achieves this:

vim.api.nvim_create_autocmd("WinNew", {
callback = function()
  vim.cmd("wincmd l")
end,
})

However, when I add this autocommand to my config, my Neotree will always open to the right of the first buffer instead of to the left. My Neotree config is all default. I’m not sure whether I need a better autocommand or a better neotree config (or both). Any help is appreciated!

The cursor should do that by default. I believe what you want is for the new window to be created on the right (by default it is created on the left).

vim.opt.splitright = true

You might also like:

vim.opt.splitbelow = true

I use both of these options because it seems much more intuitive to me.

See also

And about NeoTree, there should be a setting to choose which side it will open on by default (although I don’t use it so you should check their docs/ask the devs)