New answers tagged

0 votes

Autocommand is executed multiple times on filetype

The reason is that every time you switch to a *.py buffer its filetype is set and a new autocommand BufWrite is added to the stack. Then when you write the buffer all the autocommand BufWrite are ...
Vivian De Smedt's user avatar
0 votes

How to set autocmd for files without a filetype?

I'm assuming you don't want these autocmds to run on every file without a filetype and that there's some condition for when it should execute. The built-in way to detect extensionless files is ...
idbrii's user avatar
  • 591
1 vote

Create autocmd for downloaded files (filename contains spaces and incrementing numbers)?

setfiletype doesn't work if something else (like vim's ftdetect) already set a filetype That's the whole purpose of this command and is documented on the relevant help page. When multiple patterns ...
Matt's user avatar
  • 20.1k
0 votes

How to exclude filetype in autocmd using Neovim's Lua API?

Ok, so I came up with a workaround, which I'm not entirely satisfied with, since it doesn't make my intentions as clear. But it does now behave as I want it to. The workaround is to wrap the vim.wo ...
Jethro Cao's user avatar
1 vote

How to detect netrw directory listing from autocommand?

Thanks to Matt's answer I realised I couldn't detect a netrw directory listing in a BufEnter autocommand (unless the code is running from an after directory). So I switched to using a Filetype netrw ...
Andy Stewart's user avatar
  • 1,309
2 votes
Accepted

How to detect netrw directory listing from autocommand?

Obviously, netrw intercepts BufEnter itself to set the things up. So upon first BufEnter it depends on which autocmd was registered first: yours or netrw's one. As you want to go after netrw you can ...
Matt's user avatar
  • 20.1k

Top 50 recent answers are included