How do you set the syntax coloring for a document? - bbedit

In BBEdit how do you set the syntax coloring for a document that is unsaved and has no extension?

The language setting is in the status bar at the bottom of the editing view. For new untitled documents it says "(none)", click there to open a menu from which you can choose your desired language.
If you always want a specific language for untitled documents, there is an expert preference, which you can set with this Terminal command (for example, setting it to Markdown):
defaults write com.barebones.bbedit DefaultLanguageNameForNewDocuments -string "Markdown"
In quotes instead of "Markdown" you can use the human-readable name of the language as it appears in the menu.

Related

How to prevent VS Code from deleting the next word characters on IntelliSense auto-completion?

This question is analogous to How to keep Visual Studio autocomplete from overwriting the next word,
but targeted at Visual Studio Code instead of Visual Studio.
When a completion suggestion is selected from the list, it is inserted, but all characters from the word after the cursor are deleted. (So, nothing happens if there is a whitespace after the cursor. But if autocompletion is triggered while the cursor is placed at the beginning of a word, said word will be deleted).
Is there a way to disable this deletion behavior and get it to add the selected suggestion without deleting text to the right of the caret?
Check your settings.json files (your user settings.json and your workspace .vscode/settings.json).
You probably have a line that says:
"editor.suggest.insertMode": "replace"
You can either delete it to get the default behaviour, which is "insert" instead of "replace", or just change it to "insert".
The setting's description says:
Controls whether words are overwritten when accepting completions. Note that this depends on extensions opting into this feature.
The "insert" value's description says:
Insert suggestion without overwriting text right of the cursor.
The "replace" value's description says:
Insert suggestion and overwrite text right of the cursor.
For some languages, the default might be changed. You can check all default settings by viewing the defaultSettings.json file using the Preferences: Open Default Settings (JSON) command.
To set settings per-language, enclose them in blocks like this (example for C++):
"[cpp]": {
"editor.suggest.insertMode": "insert"
}

Disable untitled editor improvement - first line name in the title

Is there any to revert/disable the newest change for the untitled tab name (https://code.visualstudio.com/updates/v1_42#_untitled-editor-improvements)
I would prefer to the untitled-1 than the first sentence line.
As your link says:
Note: If the first line is empty or does not contain any words, the
title will fall back to Untitled-* as before.
I don't think there is a way to disable it other than to have that first line blank until you do give it a name.
The request for a setting to disable the current functionality is tracked here: https://github.com/microsoft/vscode/issues/90378 (Config to limit/disable the new Untitled tab auto-naming) or https://github.com/microsoft/vscode/issues/90495
you could upvote that issue.
---------- update, coming in v1.43:
A new setting workbench.editor.untitled.labelFormat lets you control
whether untitled editors should use the file contents as the title or
not. Possible values are content or name. Configure
'workbench.editor.untitled.labelFormat': 'name' for the previous
behavior, where untitled editors would have a short title, such as
Untitled-1.
When pasting text into an untitled editor, VS Code now automatically
tries to detect the language mode from the first line of text. For
example, pasting XML will set the XML mode automatically upon paste if
the first line contains the typical XML header .

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.

Visual Studio Code - Include context in search results

Is there a way to show context for search results in Visual Studio Code?
By default, if I search "debug" for example I might get 2 lines of code returned.
filea.rb
def debug(str)
fileb.js
function debug(str) {
I want to see what the code is for, say, 3 lines above and below each match.
filea.rb
def somefunca
puts "some func a"
end
def debug(str)
puts str.inspect
end
def somefuncb
Is it possible to add context like this to the search results?
v1.41 is adding a preview of a feature which will display search results in an editor thus allowing for some context lines around the actual search result. See search.enableSearchEditorPreview
Preview: Search Editor
In this milestone, we've started work on showing the results of a
search in an editor. This provides much more space to view search
results and allows users to maintain multiple collections of search
results simultaneously. With this release, in a search editor you can:
Navigate to results using Go to Definition-family commands, including Peek Definition and Open Definition to Side.
Rerun a search to update the list of results
View lines of context surrounding a result
Persist results to disk to be referenced later or even tracked in SCM
We will be continuing to add functionality and increase usability in
the coming releases.
Note: You can preview this feature by enabling the setting
search.enableSearchEditorPreviewstrong text.
v1.42 is adding a bit more functionality, see https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_42.md#search-editor. Like selecting the context width around the search result and running another search right in the search editor itself.
By the way, you can directly open a search editor without first doing a search in the panel with the command New Search Editor (search.action.openNewEditor) currently unbound (and renamed in v1.48). That command will always open a new Search Editor.
If instead, you wish to re-use a Search Editor (rather than opening a new one), a command is being added to v1.48:
Open Search Editor : search.action.openEditor // also unbound by default
v1.43 release notes https://code.visualstudio.com/updates/v1_43#_search-editors
In a search editor, results can be navigated to using "Go to
Definition" actions, such as kb(editor.action.revealDefinition) to
open the source location in the current editor group, or
kb(editor.action.revealDefinitionAside) to open the location in an editor to
the side. Additionally, double clicking can optionally open the source
location, configurable with the
search.searchEditor.doubleClickBehaviour setting.
You can open a new search editor with the Search Editor: Open New
Search Editor command, or using the "Open New Search Editor" button at
the top of the search viewlet. Alternatively, you can copy your
existing results from a search viewlet search over to a search editor
with the "Open in Editor" link added to the top of the results tree,
or the Search Editor: Open Reuslts in Editor command.
Note You can try out the experimental Search Editor: Apply Changes
extension to synchronize edits you make in a search editor back to
source files:
------------------------------- see edit below:
Showing the context lines does not appear to be persistent between uses of the search editor. But Alt+L acts as a toggle to show/hide the context. The value chosen for the number of context lines is persistent.
However, in v1.44 and the Insiders' Build are two new commands fro increasing/decreasing the number of context lines surrounding each search result:
{
"key": "alt+-",
"command": "decreaseSearchEditorContextLines",
"when": "inSearchEditor"
},
{
"key": "alt+=",
"command": "increaseSearchEditorContextLines",
"when": "inSearchEditor"
}
They are unbound by default - these are just sample keybindings. The context lines input box does not need to be visible for these to work. So Alt+L to enable context lines or these new commands to change the number.
In v1.46 there is a new setting to make the amount of context lines shown persistent:
"search.searchEditor.defaultNumberOfContextLines": 4, // default is now 1
and
search.searchEditor.reusePriorSearchConfiguration - Reuse the last active search editor's configuration when creating a new search editor
(defaultNumberOfContextLines seems to take precedence over reusePriorSearchConfiguration)
See v1.46 release notes: Search Editor improvements
You can single click the results which will open the relevant code in a "preview" editor. With the preview you can navigate the results list (clicking, ↑/↓, ctrl+n/ctrl+p) without opening new editors.
But it sounds like you want to avoid the preview altogether. In that case, here's a feature request, but it looks like it was closed prematurely and needs to be submitted again. The only solution that was actually implemented was a setting for placing the search results in the panel, rather than the sidebar: "search.location": "panel".

MS Word Hidden Formatting Marks

There is a problem with the formatting of certain .docx files. I click to show the hidden formatting marks. There are degree symbols ("non-breaking spaces") in between many of the words, instead of a regular space.
To solve the problem: I copy and paste the degree symbol, and then I use the "find and replace" function to replace the degree symbols with a regular space.
How do I prevent this problem from occurring in the first place?
Or, how can I automatically convert these symbols to a regular space.
Non-breaking spaces are used to keep words from breaking across lines.
As Cindy stated above, the simplest way to remove them manually is to record a macro and execute this from a Ribbon button or the Quick Access Toolbar.
According to this link (and this link it refers to), nonbreaking spaces are inserted automatically if your proofing language is set to French and you type certain characters. To prevent this from happening, you have to either use a different proofing language or disable the "Replace straight quotes with smart quotes" option. To do this, see below (and I'm quoting the previous link):
To change the proofing language, select the text and click Language on
the Review tab. In addition to choosing another language, it's a good
idea to uncheck the option to automatically detect the language.
To change the quotes replacement, click File > Options > Proofing >
AutoCorrect Options, choose the AutoFormat As You Type tab of the
dialog (not just AutoFormat), and uncheck the first option.