How can i configure javascript indentation on sublime text 2 - comments

when i use reindent function with sublime text 2, my javascript code indent according to last comment line, like this :
before reindent :
function a_function() {
some_code()
// some comment
some_code_again();
}
after reindent :
function a_function() {
some_code()
// some comment
some_code_again();
}
Someone know how can i configure indent function for comment too ?

I have found another solution.
I use package JsFormat on sublime text

Related

How to disable Shift+Enter in CKEditor 5

I would like to disable the Shift+Enter key in CKEditor 5. I will also like to strip the <br/> from the copied conent when the users paste into the editor. Basically, I just don't want the <br/> to be any where in the document. It must be a very simple setting, but I just can't find it in the documentation. Could someone help?
Thanks!
Leo
Well. It turned out pretty easy. I post it here just in case someone else wants to know. If you want to disable the Shift+Enter feature in a block, such as a paragraph. You can add the following code into paragraph.js:
// Disallow softBreak
model.schema.addChildCheck( ( context, childDefinition ) => {
if ( childDefinition.name == 'softBreak' && Array.from( context.getNames() ).includes( 'paragraph' ) ) {
return false;
}
} );

Laravel - How add break line in mail salutation?

I do not want to create a new markdown file, only to include a line break in salutation "without a paragraph".
I tested everything:
->salutation("Atenciosamente,\n\n{$app}")
->salutation("{!! 'Atenciosamente,<br>' !!}{$app}")
->salutation(nl2br(e('Atenciosamente, <br>')). "{$app}")
...
The simplest solution:
To have a line break without a paragraph, you will need to use two trailing spaces with one enter.
To break line in MailMessage or add any html, use this code:
use Illuminate\Support\HtmlString;
...
return (new MailMessage)
->line(new HtmlString("Atenciosamente,<br><br>{$app}"));
This just worked for me
...
->salutation("\r\n\r\n Regards, \r\n Support.");
You can view a good answer here.

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

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.

How to remove a newline from template?

This is a repost of my question in the Google Group. Hopefully I will get some response here.
Frequently I run into this problem. I want to generate a line of text if the text is not empty. If it is empty, do not generate the line. Illustration template:
namespace #classSpec.getNamespace()
#classSpec.getComment()
class #classSpec.getName() {
...
}
If #classSpec.getComment() returns meaningful comment text, the result looks like
namespace com.example
// this is comment
class MyClass {
...
}
But if there is no comment, it will be
namespace com.example
class MyClass {
...
}
Notice the extra empty line? I do not want it. Currently the solution is to write template as
namespace #classSpec.getNamespace()
#classSpec.getComment()class #classSpec.getName() {
...
}
and make sure the getComment() will append a "\n" to the return value. This makes the template much less readable. Also, imagine I need to generate a function with multiple parameters in a for loop. If each parameter requires complex logic of template code, I need to make them all written in one line as above. Otherwise, the result file will have function like
function myFunction(
String stringParam,
Integer intParam,
Long longParam
)
The core problem is, the template file does not only contain scripts, but also raw text to be written in the output. For script part, we want newlines and indentations. We want the space to be trimmed just like what compilers usually do. But for raw text, we want the spaces to be exact as specified in the file. I feel we need a bit more raw text control mechanism to reconcile the two parts.
Specific to this case, is there some special symbol to treat multiple lines as single line in the output? For example, like if we can write
namespace #classSpec.getNamespace()
#classSpec.getComment()\\
class #classSpec.getName() {
...
}
Thanks!
This is just a known bug see
https://github.com/greenlaw110/Rythm/issues/259.
https://github.com/greenlaw110/Rythm/issues/232
Unfortunately there is no proper work-around for this yet. You might want to add your comments to the bugs above and reference your question.
Take the example below which you can try out at http://fiddle.rythmengine.org/#/editor
#def setXTimesY(int x,int y) { #{ int result=x*y;} #(result)}
1
2 a=#setXTimesY(2,3)
3 b=#setXTimesY(3,5)
4 c=#setXTimesY(4,7)
5
this will properly create the output:
1
2 a= 6
3 b= 15
4 c= 28
5
now try to beautify the #def setXTimesY ...
#def setXTimesY(int x,int y) {
#{
int result=x*y;
}#(result)}
1
2 a=#setXTimesY(2,3)
3 b=#setXTimesY(3,5)
4 c=#setXTimesY(4,7)
will give a wrong result
1
2 a=(result)
3 b=(result)
4 c=(result)
#def setXTimesY(int x,int y) {
#{
int result=x*y;
} #(result)}
1
2 a=#setXTimesY(2,3)
3 b=#setXTimesY(3,5)
4 c=#setXTimesY(4,7)
is better but adds a space
So
https://github.com/greenlaw110/Rythm/issues/270
is another bug along the same lines
I'm experiencing the same problem. I've not been able to find a solution in the own Rythm.
To obtain a single line as result of processing several lines in the template, I've had to implement my own mechanism, in form of a post-processing. In the template, at the end of each line that I want to join the next one, I use a custom symbol/tag as token. Then, once the template has been processed, I replace that symbol/tag, together with the line break character(s) right after it, with an empty string.
For example, if you used a tag called "#join-next-line#", the template would look like this:
#for (Bar bar : foo.getBars()).join (", ") {
#bar.name#join-next-line#
}
It's not the perfect solution, but it has worked for me.

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