1

I've recently started up a project using Typescript. When I start up Vim, open up a .tsx file and open a new line, it fails to indent:

enter image description here

I then open up a regular javascript file (.js), and return to my Typescript file. I then open a new line and it indents correctly:

enter image description here

I've tried turning on / off autoindent and cindent, and I've removed my plugins (installed via Pathogen) and brought them back and the problem seems to be consistent.

I presume there is some auto indenting being triggered by the opening of the .js file that persists to the typescript file, but I have no idea how to check / debug what is going on. Any thoughts on how to troubleshoot this?

1 Answer 1

1

Welp, this worked:

autocmd BufEnter *.tsx :setlocal filetype=typescript

That seemed to do the trick for me.

2
  • 1
    The standard extension for TypeScript is .ts AFAIK. Either way, Vim doesn't have any typescript filetype as far as I can see, so it looks like you added a plugin to support this at some point? Commented Jun 29, 2017 at 23:38
  • See :help new-filetype (sections A and C) for the recommended methods of setting the filetype.
    – Rich
    Commented Aug 29, 2017 at 9:13

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.