Programmatically open markdown-preview in Atom when opening a markdown file - coffeescript

What I want to do
When I open a markdown file, I want Atom to automatically toggle the markdown-preview mode.
What I did so far
Content of my init.coffee file:
atom.workspace.onDidAddPaneItem (event) ->
if event.item.getGrammar().name is 'GitHub Markdown'
atom.commands.dispatch(atom.views.getView(atom.workspace), 'markdown-preview:toggle')
What could help to solve the problem
If the markdown file tab is open and I run the atom.commands.dispatch(atom.views.getView(atom.workspace), 'markdown-preview:toggle') command, it will work.
I think there are 2 possible approaches to do this, I juste need to figure out how to do this:
Switch current tab to the one displaying the markdown file and run the toggle command
OR
Get the markdown tab and apply the toggle command
Here is the Atom API

The package markdown-preview-opener automatically open files.
https://atom.io/packages/markdown-preview-opener

Related

VS Code change file extension at file save as dialog

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?

Is there a way to open any file as text in VS Code?

VS Code is currently my favourite text editor, except for Jupyter notebooks, which are opened as interactive python environments (let's call this 'rendered').
By itself it is nice that this is possible, but not I can live with opening them in a browser if VS Code would not render them.
There used to be a setting to avoid this behaviour ("jupyter.useNotebookEditor": false) but currently my installation does not recognise this setting anymore.
Since there are more file types that can be opened as text/source, or rendered form (e.g. html, md, svg, uncompressed pdf, etc.) and both forms can be usefull, I would be very excited to learn how to switch between rendered and source, preferably without switching global settings.
Is there a way to do this? I would hope for:
a mechanism that does not depend on (or can be overwritten by) the current jupyter extension
a mechanism that works for any file type (nice-to-have)
Are you just looking for a way to view/edit the raw json?
You can right click the file in the Explorer -> open with... -> text editor.
Or use "Reopen editor with text editor" from the command Palette (ctrl+shift+p)

How to preview asciidoc in vscode with a file with a yaml extension

I have a file which contains YAML at the top and asciidoc at the bottom. The yaml is surrounded by two lines of ---. The file extension is yaml which is required by the application where it's used.
The only way i know to get a preview out of vscode is to manually rename the file every time i need one and rename it back afterwards.
Is there a way to open the asciidoc preview in vscode while ignoring its extension, e.g. giving a hint, add a configuration or something similar?
The docs only describe that
The extension activates automatically when opening an AsciiDoc file
(.adoc, .ad, .asc, .asciidoc).
Here's a example file:
---
# yaml here
---
asciidoc here
This is surprisingly simple:
https://code.visualstudio.com/docs/languages/overview#_changing-the-language-for-the-selected-file
In VS Code, we default the language support for a file based on its
filename extension. However, at times you may want to change language
modes, to do this click on the language indicator - which is located
on the right hand of the Status Bar. This will bring up the Select
Language Mode dropdown where you can select another language for the
current file.
Tip: You can get the same dropdown by running the Change Language Mode command (Ctrl+K M).

How to review the outline of `.rmd` file in vs code?

I know vs code has ability to review ouline of markdown.
As to Rmarkdown with knitr,*.rmd files,how to review outline?
If you don't want to do install any extensions you can just simply go to the status bar and click on Plain Text and select Markdown from the menu that pops up and that will generate the outline treating the file as a Markdown file.
If you want to make this change permanent across you workspace, add this to your settings.json
{
"files.associations": {
"*.rmd": "markdown",
}
}
This is to tell VSCode to read all .rmd files as Markdown files and then it will be able to generate the outline.
Or you Could just install one of the extensions like R-Tools extension
This will parse your rmd file and generate an outline.

How to get VSCode to "open as new file" from Go To File dialog

I have recently switched to VSCode, and am loving it, except for one specific thing that drives me nuts.
My "goto" command is {Command+P}, the easy search-and-open-file bar. If I type the name of a file into this bar and it does not exist, I want to be able to hit ENTER and have it open a tab editing that file as a new file. This is the behavior I would get in old-school Windows Notepad, or in mvim :e <filename>, but I can't figure out how to do it in VSCode.
Is there a toggle or a plugin I can use to get this behavior straight out of the Go To File dialog?
Answering my own question:
No, there's no way to do this using {Command+P}. This is strictly a file finder and I've yet to see any plugin that changes the behavior.
If you're using the VsCodeVim plugin, an almost-as-good approach is just :e <file> - immediately open a new buffer editing the given file. There's no tab autocomplete this way, but you just have to live with that.