Home > front end >  Is it possible to make Vscode IntelliSense exstension that writes automatically in certain cases?
Is it possible to make Vscode IntelliSense exstension that writes automatically in certain cases?

Time:01-09

I am wondering if it is possible to make an exstension which automatically writes a \n end(were \n is an escape) when the line starts with if so when if is writen in the editor and a space is made after the if it will always automatically paste \n end in the editor. If so where can I read about the commands I need to have the exstension write to the editor?

Maybe such exstension already exist but I have had no luck finding such an exstension. It not only for if statements I am looking to do this but also for for and while statements ect.

CodePudding user response:

Yes.

You should look into the TextDocumentChangeEvent which can be subscribed to from onDidChangeTextDocument.

Then you can analyze the contentChanges and see if it matches the if pattern you want. If it does you can use the TextEdit API to perform the insertion of the newlines

  •  Tags:  
  • Related