0

I am trying to have set filetype=python automatically executed when I open a file ending in .xsh. However when I try it and then run the command set ft? it always shows me the file as xonsh. This is correct but the xonsh filetype doesn't support automatic indenting like python filetype does.

I have tried putting the following in my ~/.vimrc file

autocmd BufRead,BufNewFile *.xsh setf python

but it is always somehow getting overridden as xonsh type.

Any thoughts on how I can make this setting stick on startup?

2
  • Check the help at :h new-filetype Jan 23, 2023 at 8:40
  • The filetype xonsh and the extension .xsh are not recognised by Vim out of the box so we are missing some context, here. You probably have some custom plugin for xonsh that we don't know about.
    – romainl
    Jan 23, 2023 at 8:43

1 Answer 1

0

.xsh files are not recognized by a standard Vim or Neovim installation, so it looks like you installed a plugin for that at some point (xonsh-vim?) Try removing the plugin.

Or, if you want to keep the plugin, you can use something like this to override it:

autocmd Filetype xonsh set filetype=python

Or to have both filetypes applied:

autocmd Filetype xonsh set filetype=python.xonsh
1
  • I had completely forgotten I had installed some files under ~/.vim directory from some github project that was supposed to support xonsh. I removed those files and now the autocmd is working correctly. Jan 23, 2023 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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