Changing file EOL with vscode extension API

Viewed 16770

Can I silently change end of line sequence in VSCode?
Something like this:

vscode.commands.executeCommand("workbench.action.editor.changeEOL", "LF");
3 Answers

You can add this line to your user preferences settings (CTRL + ,):

"files.eol": "\n"

On the bottom right of vs code it will say lf or crlf. Click there and it will give an option to change.

pic of vs code

The solution is to call edit method of active TextEditor. For example:

require('vscode').window.activeTextEditor.edit(builder => { 
    builder.setEndOfLine(vscode.EndOfLine.LF);
})
Related