Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the type of the current window in vim

Tags:

vim

window

buffer

I'm using a hotkey for switching buffers and I have the problem that some windows are drawn in the main window when I'm switching through the buffers.

I was able to disable the mappings for NERDTree, the Quickfix window and Tagbar window but I always need the window name in order to achieve this with an autocommand. Finding the window name mostly requires reading through a lot of help files or even plugin sources and this is very time consuming :D

For example I use this for the quickfix window:

augroup qf
  autocmd!
  autocmd FileType qf set nobuflisted
augroup END

Is there an easier way to get the name of the current window?

like image 993
mw88 Avatar asked Dec 06 '25 10:12

mw88


2 Answers

Buffer name: :echo @%. File type: :echo &ft. Buffer number: echo bufnr(@%).

like image 139
Amadan Avatar answered Dec 08 '25 14:12

Amadan


I am not sure you are talking about vim's window or buffer.

Is there an easier way to get the name of the current window?

vim window has winnr, you can get it by calling function winnr(), same for buffer nr, get current buffer number: bufnr('%'), and to get current buffer name (the file name) bufname('%')

like image 24
Kent Avatar answered Dec 08 '25 15:12

Kent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!