I am trying to get the selected text separated by lines to make a VSCODE Extension.
const document = editor.document; const selection = editor.selection; const position = editor.selection.end; const word = document.getText(selection);
I didnt find the command to separate the selection in array for example.
Someone has the solution and the link of the API, for document constructor ?
I tried a .split(“/n”) without result too.
You can use regex to identify the newline. In Unix and Windows systems there are two types of characters that can cause newlines.
r– Carriage Return (Windows)
n– Line Feed (Unix)
So in you system you should split the selected string by both chracters.
const splittedStringArray = selectedText.split(/r?n/);