0

for example I have multiple windows in a vim instance:

+---+---+---+
|   |   |   |
| A |   |   |
|   |   |   |
+---+---+---+

Different window has different filetypes, some are plugins (NvimTree/undotree/vista), others are real editing buffer (c/c++/python/etc).

I want to define key mappings, that will run command after auto jump to the real editing buffer window. And don't run directly on plugins window(NvimTree/undotree/vista).

Currently my key mappings are:

nnoremap <silent> <expr> <Leader>1 (&filetype ==# "NvimTree" <Bar><Bar> &filetype ==# "undotree" ? "\<C-w>\<C-w>" : "").":\<C-u>BufferGoto 1\<CR>"

This key mapping could work if current window's filetype is "NvimTree" or "undotree". But it's only jump once. I want to make it a while/for loop, continue jump if the filetypes are in a blacklist (NvimTree/undotree/vista), until it's a real editing buffer window (filetypes are c/cpp/python/etc).

How could I write this vim script?

linrongbin
  • 2,967
  • 6
  • 31
  • 59
  • This question might be a fit for [vi and vim](https://vi.stackexchange.com/). – Friedrich Jan 29 '23 at 07:27
  • 3
    Vimscript is thoroughly documented in `:help usr_41` (and the very first few examples are actually while loops). You should try something first. – romainl Jan 29 '23 at 08:05

0 Answers0