9

In python, when using the vim module, it is incredibly simple to get the current window/buffer/tabpage:

current_win = vim.current.window
current_buff = vim.current.buffer
current_tabpage = vim.current.tabpage

My question is, how do you do this in pure VimL / Vimscript and what type of object is returned? I really can't seem to find this anywhere in windows.txt (:h windows).

  • :h functions makes more sense for you to find script related info. – Kent Nov 15 '15 at 17:12
15

Well… it's just as simple in vimscript.

Current window

Python:

current_win = vim.current.window

Vimscript:

let current_win = winnr()

Current buffer

Python:

current_buff = vim.current.buffer

Vimscript:

let current_buff = bufnr("%")

Current tabpage

Python:

current_tabpage = vim.current.tabpage

Vimscript:

let current_tabpage = tabpagenr()

See :help functions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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