Extract the content of OUTLINE ( or AL OUTLINE ) from VS Code - bash

Is there any bash command so that we can extract the content of OUTLINE or AL OUTLINE section of the VS Code and write the same into some text document ?

I made a VSCode extension to accomplish this.
Extension page
GitHub Repo
Install and run ctrl + shift + p -> List Symbols

If you don't get a better answer, you can try the Show Functions extension.
It can produce an output of a (clickable) list of functions and symbols into a separate editor which you can then Ctrl-A to copy and paste.
You don't say what languages you are using, I use the following for .js files:
"funcList": {
"doubleSpacing": true,
"filters": [
{
"extensions": [
".js"
],
"native": "/^[a-z]+\\s+\\w+\\s*\\(.*\\)/mgi",
"display": "/\\S* +(\\w+\\s*\\(.*\\))/1",
"sort": 0
}
]
}
which captures and displays the function name and args like:
loadCountryTaxonomy(country)
toggleSearchResultsPanel()
updatetaxArticleQueries(data)
but you can modify the regex to your requirements. I don't try to list symbols other than functions but apparently you can with this extension.

Related

Rebol2/View question: How does the layout function in Rebol2 work?

Some functions that are used in the 'layout function do apparently not exist, yet 'layout works fine. But when you try to replace the 'layout function by an adapted version containing some debugging statements, the functions and undeclared variables will immediately cause an error.
The functions BIND? and BOUND? don't show results for, for example, the used TRACK function, so there is no extra information by using those.
Special interest in the do-facets and grow-facets functions.
Here are two ways to create anonymous contexts in Rebol 2:
context [
semi-hidden-function: does [print "ok"]
set 'non-hidden-function does [semi-hidden-function]
]
use [semi-hidden-function] [
semi-hidden-function: does [print "ok"]
set 'non-hidden-function does [semi-hidden-function]
]
In the first form you may reach the context of the word semi-hidden-function:
>> probe bound? first body-of :non-hidden-function
make object! [
semi-hidden-function: func [][print "ok"]
]
But in second form you may not:
>> probe bound? first body-of :non-hidden-function
make object! [
]
I see many Rebolers use one of above forms, not only to hide but to keep the main function clean and separate.
Here I also add the functions you like to see, it is a bit long so I compressed & enbased:
You can simply paste below line to the console, copy the below text and execute the line to decompress it:
write clipboard:// decompress debase trim/lines read clipboard://
eJyNVrty6zYQrcmvWKuJPWNFqXkn0Uyq29zbpeKwgMElhRgCOABoRfn67C7Ah5xkksJje3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j7WiosH8Fqsci9zc/04t/UR8IWs3jhci
kegXdHppS/99cQO1HZ/7Efvs8aA7MPb81XdHpr/TBQCSuLNflcXiFIn35JTGO2mJYuIfgr2vmTZZ+
OXhiCQMpjojZ3hWJQ3aJCu5drDzZJRq0d4nsiCsL0N4niii+rI17X/4mYl/WxLr7C5ZY7idACQAA
You can find the definitions in the source files of the sdk
e.g
track: func [blk] [if verbose [print blk]]
in view-vid.r
Here a helper function to get the definition/source of a word/function in an unknown context and e.g. without access to the sdk
find-anon: func [ words fn /local ] [
foreach word words [
if word = fn [set :fn probe get word halt]
if block? word [
find-anon word fn
]
]
]
find-anon second :layout 'grow-facets
help grow-facets

Visual Studio Code multi-line comment for files with no extension

I'm editing a file with no extension (for example... or a file with an unknown extension, etc), and when i try to multi-line comment using Cmd+/ it doesn't do anything. I can change the extension to .py or .yaml to get the # comment feature i'm looking for, but that's a total pain. Is there a way to tell code "act like a .py extension on the file" type of thingy?... or maybe replace CarriageReturn+LineFeed with CarriageReturn+LineFeed plus # plus space ... or FORCE the Cmd+/ to work?
Finally found a couple of solutions that works... NO extensions, etc...
Just hold (mac)Option+Cmd (while in column 1), then click down arrow to multi-cursor select all of the lines, then simply type # to put that in col.1, and remainder will move over 1 column to right... you can do this again, to add another #, for example.
Also, another option is to:
-Go to Selection> ColumnSelectionMode, (put into column mode) then drag down, does "multi-select"!! ..then type # to comment lines, for example!!
I am a little surprised but this seems to work - test it out. You will need a macro extension of some sort. Here I am using the multi-command extension.
In your settings.json:
"multiCommand.commands": [
{
"command": "multiCommand.addCommentNoExtension",
"sequence": [
"editor.action.insertCursorAtEndOfEachLineSelected",
"cursorHome",
{
"command": "type",
"args": {
"text": "# "
}
},
"removeSecondaryCursors"
]
},
{
"command": "multiCommand.removeCommentNoExtension",
"sequence": [
"editor.action.insertCursorAtEndOfEachLineSelected",
"cursorHome",
"deleteRight",
"deleteRight",
"removeSecondaryCursors"
]
}
]
In your keybindings.json put these keybindings:
{
"key": "cmd+/",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.addCommentNoExtension" },
"when": "editorTextFocus && resourceFilename =~ /^(?!.*\\.)/"
},
{
"key": "shift+/",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.removeCommentNoExtension" },
"when": "editorTextFocus && resourceFilename =~ /^(?!.*\\.)/"
},
Here is a demo:
.
There are some limitations to this approach rather than a full-blown extension.
The last cursor position will not be remembered.
Empty lines will be commented - as you can see in the demo.
When block-commenting lines of different indentation, the comment #'s won't line up.
You have to use one keybinding Cmd+/ to add comments, and another binding Shift+/ to remove comments. I don't think there is a way to make it a one-command toggle.
The really interesting part of this answer is how files with no extension are targeted. In the keybindings there are when clauses that include resourceFilename =~ /^(?!.*\\.)/.
When clauses can take a regex to apply to certain keys like resourceFilename. See when clause operators. The regex /^(?!.*\\.)/ says to apply this keybinding when the filename does not include a literal .. It uses a negative lookahead asserting that there is no . following any characters.
I wasn't sure that was possible but it seems to work. The Cmd+/ command still works as it should with other file types.
You could use "when": "editorTextFocus && editorLangId == plaintext" and that would work as long as your files with no extension remained as plaintext langId files. It isn't quite as specific as the when clause I used above.

set auto complete on sublime text 3 for custom html elements

Good day,
how can I set auto complete on sublime text 3 for custom html elements, like for example if I type: dog then press tab it will become <dog></dog>.. thanks for your answer.
You can create a custom .sublime-completions file for this. Create a new file with JSON syntax in Sublime, using the following contents (of course customized to your needs):
{
"scope": "text.html - source, punctuation.definition.tag.begin",
"completions":
[
{ "trigger": "foo", "contents": "<foo>$0</foo>" },
{ "trigger": "bar", "contents": "<bar class=\"$1\">$0</bar>" },
{ "trigger": "baz", "contents": "<baz class=\"${1:myclass}\">$0</baz>" }
]
}
In the first example, typing foo and hitting Tab will insert <foo>|</foo> where | is the cursor position.
In the second example, typing bar and hitting Tab will insert <bar class="|"></bar>. The cursor will first be between the quotes following class= so you can enter your own class. Hitting Tab again will place the cursor just before </bar>.
The third example works just like the second, except that the class now has a default value. This value will be highlighted after typing baz and hitting Tab - you can either hit Tab again to keep the default value and move the cursor between the opening and closing tags, or you can enter your own value, hit Tab, and move the cursor to between the opening and closing tags.
Once you have everything set up how you like, save the file as Packages/User/HTML.sublime-completions, where Packages is the folder opened when you select Preferences -> Browse Packages....
For more information, follow the link above. To learn more about placeholders and variables, check out this documentation.
Good luck!

How to elegantly beautify a topojson code?

Is there some tool to explore the tree structure of the one-line topojson files ? (beautify)
{"type":"Topology","transform":{"scale":[0.0015484881821515486,0.0010301030103010299],"translate":-5.491666666666662,41.008333333333354]},"objects": {"level_0001m":{"type":"GeometryCollection","geometries":[{"type":"Polygon","arcs":[[0]],"properties":{"name":1}},{"type":"Polygon","arcs":[[1]],"properties":{"name":1}},{ ... }]},"level_0050m":{ ... }}}
Comments: My current method is to open the topojson .json into a text editor, and to manually look for clues while browsing. I end up sumarizing the whole by hand and keeping an handy note, something like :
{
"type":"Topology",
"transform":
{
"scale": [0.0015484881821515486,0.0010301030103010299],
"translate":[-5.491666666666662,41.008333333333354]
},
"objects": {
"level_0001m":
{
"type":"GeometryCollection",
"geometries":
[
{"type":"Polygon","arcs":[[0]],"properties":{"name":1}},
{"type":"Polygon","arcs":[[1]],"properties":{"name":1}},
{ ... }
]
},
"level_0050m":
{ ... }
}
}
But is there some more advanced tools to open, explore, edit topojson ?
Try this, jsbeautifier. I just did it this way.
If you're working with Windows try JSONedit. It's generic JSON editor, but it is relatively efficient when handling medium size JSON files (like your world-50m.json: 747 kB, 254k nodes including 165k int and 88k array nodes). Similar files to your notes can be created by deleting array elements after few initial ones (RMB + "Delete all siblings after node").
http://jsonprettyprint.com/json-pretty-printer.php
I tried this one with a file of 1.9 mb and it worked, maybe it'll work for you aswell
js-beautify from the command line generates json the way I would write them by hand.
https://github.com/einars/js-beautify
Use a JSON prettifier, example: http://pro.jsonlint.com
Use http://jsoneditoronline.org

Replace text in a Visual Studio Code Snippet Literal

Is it possible to replace text in a Visual Studio Snippet literal after the enter key is pressed and the snippet exits its edit mode?
For example, given a snippet like this:
public void $name$
{
$end$
}
If I were to enter $name$ as:
My function name
is it possible to have Visual Studio change it to:
My_function_name
or
MyFunctionName
After many years there is an answer, for anyone still coming across this question:
"Replace Whitespaces": {
"prefix": "wrap2",
"body": [
"${TM_SELECTED_TEXT/[' ']/_/gi}",
],
"description": "Replace all whitespaces of highlighted Text with underscores"
},
Add this to your user snippets. Or alternativly you can add a keyboard shortcut like this:
{
"key": "ctrl+shift+y",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "${TM_SELECTED_TEXT/[' ']/_/gi}"
}
},
Hope this helps anyone coming across this in the future
It's great. I used it to wrap things in a function with quotes. If a selection has quotes it can remove the quotes. In the snippet part, it seems to break down into:
TM_SELECTED_TEXT - this is the input
[ ' '] - regex find
_ - regex replace
gi - global flag for regex
So what I wanted is change: "User logged in" into: <%= gettext("User logged in") %>
For this in the snippet I used:
"body": ["<%= gettext(\"${TM_SELECTED_TEXT/['\"']//gi}\") %>"],
Note: you need to escape the quotein the regular expression, therefore: " becomes \".
In my case the goal was to replace a single instance of the word Authoring with Baker:
${TM_FILENAME_BASE/(Authoring)/Baker/}

Resources