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

Welp, this worked:

autocmd BufEnter *.tsx :setlocal filetype=typescript

That seemed to do the trick for me.

| improve this answer | |
  • 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? – Martin Tournoij Jun 29 '17 at 23:38
  • See :help new-filetype (sections A and C) for the recommended methods of setting the filetype. – Rich Aug 29 '17 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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