Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get 'filetype' of a buffer specified by a number?

Tags:

vim

I'm writing plugin for VIM and i need to know a filetype of buffer specified by a number. But filetype is an option - how can i get specified buffer option programmatically? I can get buffer name via bufname() vimscript function - but i did not found any function that allows me to get an option. Maybe it's some trick with bufdo?

like image 337
grigoryvp Avatar asked Mar 23 '23 11:03

grigoryvp


1 Answers

The getbufvar() function cannot just retrieve variables, but also buffer-local options (prefixed with &):

:let bufFiletype = getbufvar(bufNr, '&filetype')
like image 52
Ingo Karkat Avatar answered Apr 01 '23 22:04

Ingo Karkat