Disable preview for vscode custom text editor extension - visual-studio-code

Is there a way to disable the preview mode for my custom text editor without changing the user settings (workbench.editor.enablePreview: false)?
Like it can be done with vscode.window.showTextDocument() and vscode.workspace.TextDocumentShowOptions were you can set preview: false.

I didn't see anything helpful in the extension api. So here is a possible workaround. I assume you can listen for when your custom editor is being opened - and then run this code:
await vscode.commands.executeCommand('workbench.action.keepEditor');
after it is opened. That should take it out of preview mode. It may be the best you can do.

Related

Markdown headings not appearing in outline box in VS Code

While editing a markdown document in VS Code, the outline box does not show me the outline of the markdown document; it's completely blank/empty. I've disabled all extensions with no change in behavior (and I only had one markdown-related extension anyway, markdownlint). I don't know that this has ever worked, but it certainly has not for the last several months.
OS: Mac OS 12.3
VS Code: 1.65.2
Out of the box, Markdown headings should show up in the outline view as text nodes:
If the outline view is configured not to show strings, Markdown headers won't appear.
Take a look at the Outline: Show Strings setting in your preferences and make sure it's enabled.
This setting is called outline.showStrings. If you wish to enable it only for Markdown files, you should be able to disable the feature globally and then add something like this to your settings.json:
"[markdown]": {
"outline.showStrings": true
},
It's probably easiest to start by running Preferences: Configure Language Specific Settings... in the command palette and then selecting Markdown.

VS Code Extension Api: How to trigger Image Preview

There is method workspace.openTextDocument, but how could I trigger VS Code's built-in image preview functionality ?
You can try to disable some extensions and see if the old preview style back.
For me, this go back after I disable office viewer extension, which change the preview style.

Stop vscode preview from scrolling

Is it possible to stop vscode preview from scrolling, while editing in another tab?
I have a preview open in a splitview, and when I scroll in the document the preview is also scrolling.
Yes you can for markdown. With other languages it would be dependent upon the extension support for that given language.
Markdown you can modify the following settings to make each interdependent of each other:
JSON of each would be:
"markdown.preview.scrollEditorWithPreview": true/false
"markdown.preview.scrollPreviewWithEditor": true/false

How to open markdown preview by default to the bottom?

By default, the markdown preview in VS Code opens on the Side. I do this action quite a bit and I always have to drag a drop it to the bottom of the current tab.
I looked in my settings to see if there was a way to change this default behavior and didn't see anything that looks like it would change it.
Any suggestions on how to change this default setting?
You can try to use one of the extensions that allow to execute multiple commands and do:
markdown.showPreviewToSide
workbench.action.toggleEditorGroupLayout

VS Code. How to open JSON settings with defaults

When I'm opening settings using Preferences: Open Settings (JSON) I'm getting screen like this:
But in VSCode videos/tutorials I see people somehow have splitted window, with default settings on the left and user/workspace setting on the right:
How I can enable it?
===========================
EDIT:
I found "workbench.settings.openDefaultSettings" option and set it to true, but still my UI is different from desired on screenshot above ( I don't see search box for searching settings, also I don't see the message Place your settings in the right ... to override):
As mentioned #Juraj Kocan in comments, it happens after last VS Code updates.
This is Github issue related to this new "feature"
This one helped me:
"workbench.settings.useSplitJSON": true,
"workbench.settings.editor": "json",
How to Get to the JSON settings in Newer Versions of VS Code
In the latest versions of VS Code, you can convert back to the split JSON settings editor by changing the following settings in the (now standard) UI settings editor:
Workbench > Settings: Editor
Change from UI to json
Workbench > Settings: Use Split JSON
Checkmark to enable the option
after making this change, VS Code will open its settings as a JSON file, like in older versions of the application, rather than in the new UI. This allows you to make the changes that other answers provide, directly in the JSON (if you can find the right place and file to make them in..)
NOTE: Whether or not you actually want to use the JSON settings is a different question. Most of the time, the settings search function allows finding the same settings in the new UI. Sometimes it is difficult to get search to work though, especially if the settings are worded differently in the new UI style. There may also be cases where extensions haven't been updated to accommodate the new UI setting style, and so there is no option but to enter the JSON directly.
Not sure what do you mean by "Default".
steps to open setting by keyboard are:
press Ctrl+p (an input command line would appear at the top.)
press >
A List will appear like that in image. (search preference for all vs code settings)