VSCode extension: completion of token starting with colon - visual-studio-code

I'm working on a language extension and need to handle completion of tokens that start with a colon. What happens is that the original colon is not replaced and it ends up with two of them.
For example, to complete the symbol :foo, I type
:f
and it shows :foo in the list of options. I hit enter or tab to do the completion and it ends up with
::foo
How do I have it replace the original colon instead of appending after it?

Figured it out. The root problem was the wordPattern from the language config. I copied it from somewhere and it excluded colons.

Related

How can I turn VSCode's sub word navigation off?

In a snake_cased language, I would want to navigate variablewise and not word_wise and also exclude sigils like #, % or / from these stops.
Example:
|$here_she_goes_again; #the pipe marks my cursor position
With one Ctrl+Right, I want to land on the space before the semicolon,
$here_she_goes_again|; #the pipe marks my cursor position
then, with a Ctrl+Left, I want to return to the beginning of the line.
|$here_she_goes_again; #the pipe marks my cursor position
Somebody got this to work?
Put this into your settings.json:
"[javascript]": {
"editor.wordSeparators": "`~!##%^&*()-=+[{]}\|;:'",.<>/?"
}
Use whatever your language identifier is. I deleted the $ from the default separators to get your example to work for javascript. You can remove the other characters you indicated. The underscore was already not in the default for me. Just make sure those characters are not in the language-specific setting shown above.
You can use the extension Select By and the command moveby.regex
You are able to define a regex to search and bind this to Ctrl+Left and another to Ctrl+Right
In the key binding you can limit this to a particular languageID.

Not supporting hover variable with hyphen in vscode extension

For debugging Cobol program using vscode extension I have extended debug extension protocol. I have variables with hyphen in my cobol program e.g: emp-salary.
I have set the flag supportsEvaluateForHovers to true.
While debugging I am trying to hover this kind of variable but, value I am getting inside evaluateRequest method is NOT considering this as complete one variable name and just returning hyphen separated part of variable. For example out of emp-salary I do mouse hover over emp it is returning emp only.
My expectation is it shall return emp-salary as it is single variable name.
What exact changes I will need to implement in my code so it will consider hyphen separated variable as one variable?
Try enabling the "Use Managed Compatibility Mode" flag under Debugging. This worked for me today using VS 2019.

How to convert embedded CRLF codes to their REAL newlines in Vscode?

I searched everywhere for this, the problem is that the search criteria is very similar to other questions.
The issue I have is that file (script actually) is embedded in another file. So when I open the parent file I can see the script as massive string with several \n and \r\n codes. I need a way to convert these codes to what they should be so that it formats the code correctly then I can read said code and work on it.
Quick snippet:
\n\n\n\n\nlocal scriptingFunctions\n\n\n\n\nlocal measuringCircles = {}\r\nlocal isCurrentlyCheckingCoherency
Should covert to:
local scriptingFunctions
local measuringCircles = {}
local isCurrentlyCheckingCoherency
perform a Regex Find-Replace
Find: (\\r)?\\n
Replace: \n
If you don't need to reconvert from newlines to \n after you're done working on the code, you can accomplish the trick by simply pressing ctrl-f and substituting every occurrence of \n with a new line (you can type enter in the replace box by pressing ctrl-enter or shift-enter).
See an example ctrl-f to do this:
If after you're done working on the code you need to reconvert to \n, you can add an invisible char to the replace string (typing it like ctrl-enter invisibleChar), and after you're done you can re-replace it with \n.
There's plenty of invisible chars, but I'd personally suggest [U+200b] (you can copy it from here); another good one is [U+2800] (⠀), as it renders as a normal whitespace, and thus is noticeable.
A thing to notice is that recent versions of vscode will show a highlight around invisible chars, but you can easily disable it by clicking on Adjust settings and then selecting Exclude from being highlighted.
If you need to reenable highlighting in the future, you'll have to look for "editor.unicodeHighlight.allowedCharacters" in the settings.

How can I use curly braces in Netbeans code templates for example for an slf4j template?

Creating a Netbeans code template for creating an slf logger is described here:
http://wiki.netbeans.org/SLF4JCodeTemplate
However creating code templates for log statements, e.g.
logger.debug("Something: {}", var);
is harder than expected because the template language doesn't balance curly braces. This means it will end the capture at the first ending curly brace.
There exist some examples, like for example How to get current class name in Netbeans code template? but they do not touch into the curly brace issue.
I have tried to escape them in every way I could think of so farm including:
${LOGGER default="logger" editable=false}.debug("${logMessage}${: '{}'}", ${EXP instanceof="<any>" default="exp"});
and
${LOGGER default="logger" editable=false}.debug("${logMessage}${: \{\}}", ${EXP instanceof="<any>" default="exp"});
but no luck. Also my google skills have been failing me so far.
Turns out there is a simple solution. I didn't find it anywhere near anything about netbeans code templates, but under a question about freemarker:
How to output ${expression} in Freemarker without it being interpreted?
Basically the answer is to use r"..." around the code, like this:
${LOGGER default="logger" editable=false}.debug("${logMessage}${:r"{}"}", ${EXP instanceof="<any>" default="exp"});
Now this can be assigned to sld, so I can type slt, expand it to:
logger.debug("logMessage: {}", <last variable>);
Where "logMessage" is selected (so I can overwrite it with something useful, one tab selects ": {}" so I can delete it if I want to log without parameters and a last tab selects which is the last assigned value (in case I want to replace or remove it).

adding another letter to already existing autohotkey

My title doesn't make any sense, but here's an example of what I want to do:
If I type abc it should be replaced with ABC. Additionally, if I type abcc it should replace with Always Be Closing. In other words abc auto-capitalizes, and abcc spells this acronym out.
Currently, I have...
:*:abc::ABC
:*:abcc::Always Be Closing
...so when I type abcc it just comes out as ABCc
I know there's a lot more to it than this, but I can't figure out (new to this). Thanks for any help.
The * are your hotstring options, where the * indicated that it will replace it as soon as you type the last letter c in abc. Removing the * like this will make it replace only if you press a non-alphanumeric character: (or enter, or whatever)
::abc::ABC
::abcc::Always Be Closing
The above lines is probably what you want. (You can add the c option to make it case sensitive for example, if you want)
Also see the documentation of Hotstrings, in particular the Options block.