How do you get Notepad++ to treat # (hashtag) like a comment? - sql

I have an SQL export file from my server with comments. The line comment operator used was the hashtag #. Notepad++ does not treat this like a commented out line, as in, the color does not change and any words such as like and while are changed to bold blue.
When you run the script on the server to install the SQL, it runs fine, the comments are treated as they should be. How do you tell NPP that the # operator is supposed to comment out the line? Both show the color and have Ctrl-k add a # in front of the line.
Note: I added commentLine="#" in the langs.xml file with no luck.

View -> User defined Dialogue -> Comment & number -> Comment Line
There you type in "#"
Before this you need to define a new language in the upper buttons.
What means, that the whole rest of the syntax isn't highlighted anymore.
But you could define it that way, how you want to. So you have an individual Syntax Highlighting including the commenting via "#"

Related

Intellij: how to convert indents for all files

I know how to convert indent for a single file. I go to edit -> convert indent -> space/tab.
But I want to do this for all files under a directory.
I try click on a directory and then go to edit -> convert indent, but the options are grayed out.
You can use the shortcut Ctrl+ALT+L (Windows/Linux) or ⌥⌘+L (MAC OS X) and select the Rearrange entries option to reformat the code in the current file or reformat a module or directory.
You can also Right-click a module, file, or directory from the context menu and select Reformat Code and also select the Rearrange entries option.
This will convert the indents for all files/directories selected:
This works on most of the Jetbrains IDES (iDea, PyCharm, WebStorm, RubyMine, and so on.)
It seems there is no such dedicated option in IntelliJ, but you could just work around it using a "low-level" Replace All action.
Open the Edit → Find → Replace in Files... dialog
In case you want to convert spaces to tabs, you should
Enter in the Find field (i.e. four spaces (or whatever number of spaces the project is currently indented with))
Press the Regex search modifier (Alt + X)
Enter \t in the Replace field
NB: In case you have valid strings with 4+ spaces in them, they will get replaced too. In most use cases, however, this is not happening.
In case you want to convert tabs to spaces, you should do the same as above, but swap the Find and Replace field contents
NB: Again, if you have valid strings with tabs in them, they will get replaced too. I haven't had this use case, because I've only needed to convert in the opposite direction.
You will probably also want to set a File mask in order not to replace spaces in code-irrelevant files

jEdit in hard word-wrap mode: insert comment character automatically?

Probably quite a niche question, but I believe in the power of a big community: Is it possible to set up jEdit in way, that it automatically inserts a comment character (//, #, ... depending on the edit mode) at the beginning of a new line, if the line before the wrap was a comment?
Sample:
# This is a comment spanning multiple lines. If I continue to type here, it
# wraps around automatically, but I have to manually add a `#` to each line.
If I continue to type after the . the third line should start with the # automatically. I searched in the plugin repository but could not find anything related.
Background: jEdit has the concepct of soft and hard wrap. While soft wrap only breaks lines visually at a character limit, it does not insert line breaks in the file. Hard wrap on the other hand inserts \n into the file at the desired character count.
This is not exactly what you want: I use the macros Enter_with_Prefix.bsh to automatically insert the prefix (e.g., #, //) at the beginning of the new line.
Description copied from Enter_with_Prefix.bsh:
Enter_with_Prefix.bsh - a Beanshell macro for jEdit
that starts a new line continuing any recognized
sequence that started the previous. For example,
if the previous line beings with "1." the next will
be prefixed with "2.". It supports alpha lists (a., b., etc...),
bullet lists (+, =, *, etc..), comments, Javadocs,
Java import statements, e-mail replies (>, |, :),
and is easy to extend with new sequence types. Suggested
shortcut for this macro is S+ENTER (SHIFT+ENTER).

Intellij: add space after double slashes in line comment

Is there a way in Intellij IDEA (I'm using version 13) to automatically add a space to line comments between the two slashes and the text:
If I enter :
//This is a comment
I'd like to get the following when I run a code reformat (Ctrl-Alt-L on Windows)
// This is a comment
It's for Javascript files but should be working for other file types.
If you press CTRL / or CMD / it will put // at the beginning of the line and the comment will be properly indented.
// comment with two indents
For this to work Comment at first column must be checked in Editor->CodeStyle->Javascript->Wrapping and Braces->Keep when reformatting like mentioned in another answer.
This screenshot is for Java, but it works the same for Javascript. Just choose javascript in the menu
If you want to write multiline comment you can use CTRL SHIFT / or CMD SHIFT / That way when you go into new line, you will have one space after the comment start
/*
* there is space before this*/

How do I auto indent a long method after typing in the finish semicolon in XCode5?

I have a long method, after I type it in, it looks like this:
[someObj action1:param1 action2:param2 action3:param3 action4:param4];
But I want it to become like this... :
[someObj action1:param1
action2:param2
action3:param3
action4:param4];
...automatically after I type in the last semicolon.
I just saw a video that did this, so how do I do that?
(It is a paid video so can't give link here)
For the question text:
[someObj action1:param1 action2:param2 action3:param3 action4:param4];
if you have already entered that on one line just select the space between parameters and return
That will tend to alligh the colon ":" characters on multiple lines.
To auto-indent already entered code select the text that you would like auto-indented and then control i and that selection will be indented to Xcode rules.
I use that all the time.
If you just want to move a selected block of code to the left command [, to the right command ]
Have a look at https://github.com/travisjeffery/ClangFormat-Xcode.
It will reformat your code to adhere to style rules, like Chromium's for example, where the line length is 80 chars max.
In this case, the method will be wrapped as you mentioned if it's more than 80 chars.
You can either reformat on a particular key combination, or on each save.

Intellij - Reformat Code - Insert whitespace between // and the comment-text?

I am working with another human being on project from that the professor expects to have uniform code-style. We have written large separate junks of code on our own, in which one has written single line comments without a white-space between the single-line-comment-token and the other one has inserted a white-space. We are working with IntelliJ and have failed to find an option to enable the Reformat Code function, to insert a white-space.
TLDR:
Can you tell us how to convert comments from that to this in IntelliJ?
// This is a load bearing comment - don't dare to remove it
//This is a load bearing comment - don't dare to remove it!
You can do a global search and replace (ctrl-shift-r on windows with default keyboard layout, or Replace in Path under the Edit/Find menu).
Check the regular expression option and enter //(\S.*) as the text to find and // $1 as the replacement. Check the whole project option, and clear any file masks. You can single step through the replacements, or simply hit the All Files option.