On some files I need to change standard save as file dialog.
I want to use custom command that executed 'workbench.action.files.saveLocalFile' command with some params that can change availible file extensions.
Where I can find the params if they exist?
Another way:
Custom command with showSaveDialog (my own vscode.SaveDialogOptions)
Close unsaved editor
Open saved file in editor
At step 2 I use 'workbench.action.closeActiveEditor' command, but I can see confirm dialog (Do you want to save the changes...)
How to remove this confirm?
Related
I have a file foo.txt and open it with my Custom Editor Extension.
When my extension edit it, I can know the change by fire onDidChangeDocument Event.
But how can I know change from outside?
For example, I should update my web-view when some other program edit foo.txt.
You use a FileSystemWatcher.
Also read: FileSystemProvider.
In my extension I use CodeActionsProvider and HoverProvider.
This functionality works well when I open a file - it shows me the problems and the hovers.
However I want to apply CodeAction and Hover on open files:
User opens "abc.txt".
User changes something in "abc.txt" and save it.
My extension does its magic and creates some new hovers and problems. "abc.txt" is still open.
The new hovers and problems are presented to the user in "abc.txt" without reopenning the file. <-- How??
I managed to present the new hovers and problems by executing the save command: workbench.action.files.save. However, I couldn't find any way on how to do it without saving the file.
How can I trigger a file inspection without saving it?
I have a snippets file called tutorials.code-snippets that I would like to delete from VS Code. I can't see anything in the docs that tells you how to delete a custom snippets file. How can I delete it?
Open the custom snippet
Right click on the tab
Click on Copy Path
Open the copied path (Make sure to delete the filename at the end of the path before opening it, or you will open the actual file)
Delete the file
I did it a bit differently from the anwser above. I directly removed the snippet from the .json file, and I find it a better way to delete the snippet, because you can also look at your other snippets and edit them in the json file, which is more comfortable than just deleting the file.
I use the snippet creator by Nikita Kunevich, so maybe if you use a different tool to create snippets they might look differently.
Here's how to do it:
Click: File > Preferences > User Snippets
then such a window will appear:
then select the language, for example javascript, and then you will have a window appear:
(these are my custom snippets)
and here you can basically edit everything to suit your needs, just remeber to hit ctrl+save once you're done!
When creating new file in VS Code, it just opens a blank empty file right away.
Is there a way to create a specific type of new file, like in Notepad++ you can choose the language for the file. In VS Code you get to choose the file extension only when saving the file for the first time.
It'd be a bit faster to create a new, for example, JavaScript file instead of creating empty file and saving it as .js file and then writing to it.
So far I've created files with basic Notepad (with the "show file extensions" option enabled from File Explorer) and when naming the new file, writing the extension at the end instead of .txt
You could just open the integrated terminal CTRL+`` and touch your file.
The keyboard shortcuts mentioned by #CountingStuff in this comment worked.
Here are the step-by-step instructions:
Create a new file:
Ctrl+N
Change the syntax language:
Ctrl+K M
In the drop down that appears, auto-complete or manually choose a language option.
The vscode documentation for this can be found here:
https://code.visualstudio.com/docs/languages/overview#_language-id
I've remapped my keyboard shortcuts so that CTRL+N triggers the "File > New File" menu item. Now, when I press CTRL+N it adds a new entry in the file explorer and I can add a new file from there. I can also utilise VSCode's file explorer creation mechanism to create files in subfolders by pre-fixing the file with the directory structure, so typing src\index.js will create a new file named index.js in the src directory.
Reference: https://www.youtube.com/watch?v=2QBYlfSQA6s
While the command line is very useful for most of the tasks, I sometimes resort to a graphical file explorer (like Nautilus, Thunar, PCmanFM). I would like a keyboard shortcut or a context-menu entry to open such a graphical file explorer _in the current directory. I know the converse is possible with nautilus-open-terminal. Is there currently a way to do that?
It may require writing a perl-extension, but I do not know enough of perl and urxvt to find how to capture the current PWD.
Assuming you're using Bash as your shell, here's an alias you could add to your .bashrc:
alias nh="nautilus file://$(pwd)"
I called it nh for "Nautilus here". So from the comman-line you would simply type:
nh
for a nautilus window in the shell's current directory.
I have no idea what's involved in adding something to the urxvt context menu - sorry.
Well, I quickly hacked a small extension to do this: https://github.com/raphaelfournier/urxvt-perl.
The opening of the file browser can be triggered with the right-click menu or a keyboard shortcut. The selection can be a directory, but also a filename, which will then be opened by the application associated with it in the file browser.