As title. After doing
windo it seems like Vim forgot where it started.
I just found that NeoVim provides some functions to do so easily:
local cur_win = vim.api.nvim_get_current_win() -- do your windo, for example: vim.cmd("windo if &buftype != 'nofile' | let g:non_float_total += 1 | endif") vim.api.nvim_set_current_win(cur_win)
And since my problem was originally asked in context of Vim before edit(yeah, it's embarrassing that I'm writing NeoVim plugin in Lua but always resort to VimScript first :p ), here is an answer that resolves that, by the power of ancient great people:
" Just like windo, but restore the current window when done.
function! WinDo(command) let currwin=winnr() execute 'windo ' . a:command execute currwin . 'wincmd w' endfunction com! -nargs=+ -complete=command Windo call WinDo(<q-args>)