Comment/Uncomment multiple lines in Snowflake (German keyboard) - snowflake-cloud-data-platform

how can I comment or uncomment multiple lines in Snowflake?
The docs says CTRL + / but because I got a german keyboard the / is a capital 7. And CTRL + SHIFT + 7 is not working either.
Is there any way to comment and uncomment multiples lines in Snowflake if you dont use an US-Keyboardlayout?

Without using any keyboard shortcuts. You can enclose the lines with /* and */
/*
This is a comment
and another comment.
this one too.
*/
This is NOT a comment.

For Mac User: Select the multi-line and press 'command'& '/' keys

Related

Number of Tabs I do get after striking Tab key in Vim Insert mode

I am learning C programming.
I met a problem about vim configuration.
The following is my vim setting written in .vimrc:
set nu
set shiftwidth=4
set tabstop=4
set softtabstop=8
set autoindent
set cindent
set smartindent
syntax on
In order to see where the tabs are, I have used :set list:
#include <stdio.h>$
int main(void)$
{$
^Iprintf("ab\n");$
^Ireturn 0;$
}$
Now in line 4 under Insert mode, I want to see how many tabs I can get after I strike Tab key in different locations.
Here's the result:
When I strike Tab after n, I get ^Iprin^I^Itf("ab\n");$.
When I strike Tab after \n, I get ^Iprintf("ab\n^I^I");$.
The above two situations are quite understandable to me.
But when I strike Tab after a, I get ^Iprintf("a^Ib\n");$.
This is beyond my understanding.
Can anybody explain why there is only one tab replaced?
I thought there should be two because softtabstop takes up 8 spaces which is two times tabstop (4).
This is the result of the interaction between your softtabstop and (regular) tabstop.
Your softtabstop says when hitting the Tab key, the results should be aligned with multiples of 8 columns. When you strike Tab after a, you're already at column 13, so just one 4-width tab character is enough to get there. In the other cases you were at 16 and 8, respectively, so it took two 4-width tab characters to align to your 8-width soft tab.
PS: if you want weird behaviours (not recommended of course), set tabstop=3 softtabstop=8. Then you get combinations of spaces and tab characters when you hit the Tab key.
PPS: All this is part of why I don't like literal Tab characters. They're unstable, their display depending on each developer's tab-stop settings. In my organization, I push hard for everyone to use :set expandtab (or the equivalent in each developer's editor) and use space characters for stable and reproducible display. The only place I tolerate tab characters in my work is in makefiles, where I don't have a choice.

Find the ngDocs comments that have no methodOf (regex)

I have built an angular1 application, which has thousands of methods in many many controllers, etc.
During the development, I wasn't too careful when creating docs comments. I have spent the night fixing the format to be able to generate docs, again.
Now I get this error message: Don't know how to format #ngdoc: method.
I have learned from other, similar questions, that this happens (or might happen), when the #methodOf attribute is missing. The Error message does not clarify where this happens.
So I'd like to find all those ngdoc comments, which are not properly formatted, using the IDEs (PhPStorm) search function and a regular expression.
This the current Expression, that I have come up with:
\/\*\*\s*\n\s\*\s#ngdoc method\n(\s\*.*(?<!methodOf)\n)*\s\*\/
From these comments, I'd like it to find the second one, only:
/**
* #ngdoc method
* #name app.admin:AuditLogController#auditsWatch
* #methodOf app.admin:AuditLogController
*/
/**
* #ngdoc method
* #name app.admin:AuditLogController#auditsWatch
*/
/**
* #name app.admin:AuditLogController#auditsWatch
*/
Test it here: https://regex101.com/r/wfIiZJ/1
So basically I'd like it to find any comment, that starts off with
/** and #ngdoc method, ends with */and does not have methodOf somewhere in between.
The closest I have come, is this one:
\/\*\*\s\n*.*(?!methodOf)\n*.*\n\s\*\/
https://regex101.com/r/qpt8G7/1
I'll continue trying, but maybe someone has the solution and is willing to share.
Any help here is greatly appreciated!
Okay, so right after I posted the question and thought it through from the beginning, I got the solution.
The regex looks like this:
(\/\*\*\s*\n\s*\*\s#ngdoc method\n)(((\s\*\s)(?!#methodOf).*\s*\n)*)\s*\*\/
https://regex101.com/r/Ep50XQ/1/
I divided it into several groups.
(\/\*\*\s*\n\s*\*\s#ngdoc method\n) finds
/**
* #ngdoc method
So any comment which documents a method.
(\s\*\s)
Takes care of a new comment line, consisting of possible white spaces, one *, followed by more whitespaces.
Here lies the culprit I fell into before.
I need to be aware of the current cursors position.
(?!#methodOf)
Makes sure the line does not start with #methodOf
In combination (((\s\*\s)(?!#methodOf).*\s*\n)*)
ensures a line within the comment, which does not start with #methodOf, can have any characters besides (.*), possibly some white spaces (\s) and ends with a line break. This can be repeated any number of times (*).
The last part
\s*\*\/
is this: */which ends the comment block and the regex.
Thank you, StackOverflow, for helping me think.
Maybe it can help somebody else, though.
You can make use of a tempered greedy token here:
(?s)\/\*\*\s*\*\s*#ngdoc method\n(?:(?!\*\/|methodOf).)*\s\*\/
^^^^^^^^^^^^^^^^^^^^^^^
See the regex demo
The pattern matches:
(?s) - enables . to match line breaks
\/\*\* - a literal /** substring
\s*\*\s* - a * enclosed with 0+ whitespaces
#ngdoc method\n - literal #ngdoc method substring followed with a newline
(?:(?!\*\/|methodOf).)* - the tempered greedy token matching any char, 0 or more times, that is not the starting point of a */ literal char sequence or methodOf substring
\s - a whitespace
\*\/ - a */ literal char sequence.
Note that you may consider using \R or \r?\n to match line breaks if there may be a CR before LF.

regex: extract text between two string with text that match a specific word

I'm refactorying a very big C project and I need to find out some part of code written by specific programmer.
Fortunately every guy involved in this project mark his own code using his email address in standard C style comments.
Ok, someone could say that this could be achieved easily with a grep from command line, but this is not my goal: I may need to remove this comments or substitute them with other text so regex is the only solution.
Ex.
/*********************************************
*
* ... some text ....
*
* author: user#domain.com
*
*********************************************/
From this post I found the right expression to search for C style comments which is:
\/\*(\*(?!\/)|[^*])*\*\/
But that is not enough! I only need the comments which contains a specific email address. Fortunately the domain of email address I'm looking for seems to be unique in the whole project so this could make it simpler.
I think I must use some positive lookahead assertion, I've tried this one:
(\/\*)(\*(?!\/)|[^*](?=.*domain.com))*(\*\/)
but it doesn't run!
Any advice?
You can use
\/\*[^*]*(?:\*(?!\/)[^*]*)*#domain\.com[^*]*(?:\*(?!\/)[^*]*)*\*\/
See the regex demo
Pattern details:
/\* - comment start
[^*]*(?:\*(?!\/)[^*]*)* - everything but */
#domain\.com - literal domain.com
[^*]*(?:\*(?!\/)[^*]*)* - everything but */
\*\/ - comment end
A faster alternative (as the first part will be looking for everything but the comment end and the word #domain):
\/\*[^*#]*(?:\*(?!\/)[^*#]*|#(?!domain\.com)[^*#]*)*#domain\.com[^*]*(?:\*(?!\/)[^*]*)*\*\/
See another demo
In these patterns, I used an unrolled construct for (\*(?!\/)|[^*])*: [^*]*(?:\*(?!\/)[^*]*)*. Unrolling helps construct more efficient patterns.

Add specified comment pattern in c

I'm wondoring if there exists a function of a software tool which allows me to add empty comment pattern to the variables defined in methods in c, for example /**...*/
I've tried using eclipse and vim. The best I can do is to add just comments for functions at the begining. I'd like to know if I could add such pattern wherever I want.
I know that use short cut key like Shift+Ctrl+/ can make a sentence as comment, but in the format of //. If there's a way for me to change this format to the one I want, that would be also a great help. Thanks!
In Notepad++ you can do that!
Check this link
In the web page search for Comment / uncomment section.
With The NERD Commenter, you can surround a selected text or variable with command delimiters via its <Leader>cc mapping:
[count]<Leader>cc NERDComComment
Comment out the current line or text selected in visual mode.
With
let NERDComInsertMap='<c-c>'
you can define an insert mode mapping that inserts the comment prefix and suffix at the current position, and puts the cursor in between. The comment syntax is filetype-specific and can be configured via the 'commentstring' option.
To change the comment prefix / suffix, you have to customize the plugin (in your ~/.vimrc), as described by :help NERDCustomDelimiters, e.g. for Java:
let g:NERDCustomDelimiters = {
\ 'java': { 'left': '/**', 'right': '*/' }
\ }
For unknown filetypes, you can also use 'commentstring', as this is what the plugin falls back to.

How do I store text in database with line breaks or paragraph

In my application I have Terms for Apps. Before I used to put this in front-end with HTML .
But now I need to put this text in database in a column called AppTerms inside table called App.
I referred to this link in stackoverflow and followed like this :
UPDATE [AppsDatabase].[dbo].[App]
SET AppTerms = 'This App has no minimum term.' + CHAR(13) +
'This App is built and is supported through the standard way of using the company online support.' + CHAR(13) +
'Incorrectly formatted data will not be formatted but may be charged for.'
WHERE AppID = 8
GO
But I am not getting line breaks here. And also can someone tell me how can i put bullet points in each line?
If you are showing HTML you need to store </br> instead of CHAR(13).
Displaying this text in HTML will yield the correct display. In addition you can wrap a paragraph in <p>...</p>.
For bullet lists look at http://www2.gol.com/users/billp/articlehtml/bullet.html.
This is under the assumption that you take the text out and display in HTML.
It might be too late, yet, I had the same problem...
The solution I came up with is to store paragraphs(or lists... or whatever) in a separate child table and handle the formatting at the server programming language level.
It should work. In HTML you could use the </br> tag.
You want the application to render HTML with line breaks, but you're storing plain text.
You need to store HTML instead. Encode the line breaks using the <br> element.
Try this:
UPDATE [AppsDatabase].[dbo].[App]
SET AppTerms = 'This App has no minimum term.<br>' + CHAR(13) +
'This App is built and is supported through the standard way of using the company online support.<br>' + CHAR(13) +
'Incorrectly formatted data will not be formatted but may be charged for.'
WHERE AppID = 8;
If you want to encode bullet points, check out the <ul> and <li> elements.
This is a data formatting issue more than a SQL Server issue. You would have had the same problem if you tried to store the data in a file instead of a table.
The W3C specification for HTML Text explains how white space is handled in HTML:
In HTML, only the following characters are defined as white space
characters:
ASCII space ( )
ASCII tab ( )
ASCII form feed ()
Zero-width space (​)
Line breaks are also white space characters.
[...] user agents should collapse input white space sequences when producing output inter-word space.
Line breaks are equivalent to spaces, and multiple white space characters are collapsed to a single space in the output.

Resources