Changing EOL to "LF" using Extension API - visual-studio-code

I have created a simple extension for changing EOL type of the opened document.
But the executeCommand() wasn't working.
It's just showing a popup command to choose "LF" or "CRLF" option.
const vscode = require('vscode')
vscode.commands.executeCommand('workbench.action.editor.changeEOL', 'LF')
How to directly executes command to change EOL to "LF" without select popup option?
VS Code v1.44.0

Related

Create custom keymap in vscode

I want to create a custom keymapping in vscode that would help me write special text faster when writing in LATEX.
Example of what I mean :
I'm using the \color{choosen_color}{text} command in latex.
I have written "some text" and within that I want to use the above command over the "text" word.
Instead of having to write it manually, I want that if I select "text" and then press Ctrl+Alt+c, vscode automatically writes \color{}{text} and place the cursor between the first brackets.
Any idea how to do it ?
Ok, so thanks to #rioV8 I figured it out.
What I was looking for is the VsCode Keymapping snippets.
More about it here :
https://code.visualstudio.com/updates/v1_9#_insert-snippets
Visual Studio Code snippet as keyboard shortcut key

VsCode: Is there a keyboard shortcut How to make VS Code treat files without extension as a certain language?

Is there a keyboard shortcut How to make VS Code treat/reopen/reload files without extension as a certain language?
Just to be clear, here's my use case:
Sometimes I have a big JSON I need to read so I copy it in VsCode new file but since it's a new file I have to save it a s JSON extension to read it in the correct format. So my question is: Is there a way to specify the language for this new file(without extension) to open it as JSON for example?
Thank you
I found these two options:
// The following example associates all files in a folder `somefolder` to PHP:
"files.associations": {
"**/somefolder/*.*": "php"
}
https://code.visualstudio.com/docs/languages/overview#_can-i-map-additional-file-extensions-to-a-language
// The default language mode that is assigned to new files.
"files.defaultLanguage": "html"
https://code.visualstudio.com/docs/languages/overview#_how-do-i-set-the-default-language-for-new-files
Add the lines of your choice to settings.json.
Nevermind guys I found it:
The feature is called Change Language Mode.
The default shortcut is Ctrl+K M if you want to customize it here's the name of the command:
workbench.action.editor.changeLanguageMode
You can also click in the lower right of VSCODE window to change the language mode:

Pascal extension on VSCODE (pascal auto indent)

I'm trying to use pascal on vscode and i had to download some extensions, one of them ('Pascal formatter) what me to config this variables:
Indicates the engine app path (required)
"pascal.formatter.enginePath":
Indicates the configuration file for the selected engine (optional)
"pascal.formatter.engineParameters":
But im on ubuntu and i dont know where is that, bc the enginepath default its "C:\FPC\2.6.4\bin\i386-win32\ptop.exe". what i need to do here?
I want to use this extension because vscode its not auto-indenting my code while i write it.
If i write this in vscode :
program example;
var
i:integer;
begin
i:=4;
i:=4+5;
end.
but i want the code to autoindent while im writing like this:
program example;
var(*after hit enter it autoindent*)
i:integer;
begin(*after hit enter autoindent*)
i:=4;
i:=4+5;
end.(*detect end and get it to the same indent than begin*)

VSCode search/go to definitions

I searched in vscode site but I couldn't find information on the following:
Is there any way to search definition in other files.
For example:
In sublime text I can open command pallette (ctrl+p) and write 'User.php#delete' - this will find the method and if i click enter I will go the the specific file and in the line where method 'delete' is.
Does the functionality exist in VSCode (or with extension).
Thanks
There are multiple options to search function/definition.
According to your convenience, you can choose one of the below options :
Best shortcut: Ctrl+Shift+O and type your function name.
Press Ctrl+P for "quick open", then you can use # or #: The latter is handy to see all the symbols in the file grouped by classes, constants, fields, methods
Press Ctrl+T to searches across files, not just the current file.
Hover the method and press crtl. The method will be underlined and show a tooltip with definition. Mouse left click = go to definition.
yes, in command palete enter # symbol (without preceding >) end method name.

vscode: Api call for inserting newline respecting the indentation

I am looking for vscode API call for inserting newline respecting the indentation
Something like this...
vscode.commands.executeCommand("cursorDown");
// this just puts the cursor in the next line
You can use the editor.action.insertLineAfter command. I tried it with the command palette using vscode 1.22.2 and it does what your gif shows.