Change comment-char in Notepad++ to "|" - comments

How do I change # to | as a comment sign in Notepad++?
In which language syntax comments are |?

I don't know what language have | as comments sign.
You have to define your own language rules. You can choose the comments sign in the file langs.model.xml (in the Notepad++ installation directory), see the attribut commentLine= for each language.

In SynWrite app you can change comment-char for "Text files" lexer: call "Options - Customize lexer" dialog, fill field "Line comment string" with "|".
Now command "Comment lines" adds "|".

Related

Command line options to jump to search term in .txt file searched from within Xbench (and opened in EmEditor)

I am using a glossary search program called Xbench, and it allows you to use command line parameters to automatically jump to the relevant line in the file where your search term is. The developer told me to look for tips on how to achieve this with EmEditor # https://docs.xbench.net/user-guide/xbench-settings/
There, it is explained how to achieve this with Textpad and Notepad++.
See:
For example, to configure TextPad 4 for line positioning, you must
select there the Textpad executable and specify the following in
Command-Line Parameters: $filename($line,$column). Similarly, to
configure Notepad++, you must select its executable and specify the
following in Command-Line Parameters: $filename -n$line. Other text
editors will require different values for this field. Please check
your text editor’s documentation for the suitable values.
I had a look at EmEditors command line options # http://www.emeditor.org/en/howto_file_file_commandline.html, but can't figure out how to do this. Can someone help me?
Michael Beijer (technical/patent translator)
Please try this:
$filename /l $line /cl $column
If a file name contains a space, you might need to use this:
"$filename" /l $line /cl $column

Use both "-" and "+" for command style in boost program options

po::command_line_style::style_t style = po::command_line_style::style_t(
po::command_line_style::unix_style |
po::command_line_style::case_insensitive |
po::command_line_style::allow_long_disguise );
po::store(po::parse_command_line(argc, argv, commandOptions,style), vm);
po::notify(vm);
The command line that I am trying to parse is of the form
-abc abc_value +xyz xyz_value
I would like to configure the boost program options to use both "-" and "+". I read the help and it states that "The allowed character
for short options is also configurable." But I could not figure out how to do it.
Any help will be much appreciated.
The configurability just refers to the following style flags:
allow_dash_for_short
Allow "-" in short options.
allow_slash_for_short
Allow "/" in short options.
You cannot freely choose a short-option leader character.

Reverse all line of text in Sublime Text

I have a file where I have multiple lines. Is there an option in Sublime Text 3 to reverse whole line ? Like
ABCDEFG
to
GFEDCBA
if someone need to do the following operation.
12345
67890
abcde
|
to
|
v
abcde
67890
12345
click Edit---->Permute lines--->Reverse and it will reverse all lines you selected in a file.
You best bet would definitely to take Leonid's advice and use a different tool, but if you are curious as to how one might do that in Sublime you have two options.
First go to Tools->New Plugin and paste the following code into the file:
import sublime, sublime_plugin
class ReverseCharactersCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
stringContents = self.view.substr(region)
self.view.replace(edit, region, stringContents[::-1])
Following that select the different sections of the document that you want reversed and run the follow command from the console
view.run_command("reverse_characters")
Here is an image of that workflow.
The import section of that code is the:
stringContents[::-1]
Which is an idiomatic way of reversing a string in Python.
Alternatively you could go checkout this follow git repository and which has the same code and a convenient command palette options specified for you :)
https://github.com/MattSeen/ST_ReverseCharacters
In vanilla sublime:
Select the text to reverse
Open the Find menu (Ctrl+F)
Ensure "In selection" and "Regular expression" options are enabled
Search for . and click "Find all" (⌥+Enter)
Now each character of the selection is highlighted with its own cursor.
Click Edit > Permute selections > Reverse
It's not elegant but it is straightforward and repeatable. If you already have the cursors, all you need is step 4.
Not inside Sublime Text, but in Linux/OSX the rev command-line utility does just that - rev file.txt reverses every line of the file.

Remove the line break "\n" after a "\" character in Notepad++

I have a CSV file that contains about 100'000 records some of which have been broken into multiple lines at a "\" character in the source data during the export. Can any one help me with an expression to remove any line breaks that follow the "\" character in the data.
In the "Replace" dialog, select "Extended" from the "Search Mode" section (bottom left of the dialog).
In the "Find what" box type: \\\n
In the "Replace with" box type: \\
Hit "Replace All"
Enjoy
Good afternoon.
Did you try clicking on the "Edit" menu and "Convert line breaks" from the application "Notepad ++"?

Block Comments in a Shell Script

Is there a simple way to comment out a block of code in a shell script?
In bash:
#!/bin/bash
echo before comment
: <<'END'
bla bla
blurfl
END
echo after comment
The ' and ' around the END delimiter are important, otherwise things inside the block like for example $(command) will be parsed and executed.
For an explanation, see this and this question.
There is no block comment on shell script.
Using vi (yes, vi) you can easily comment from line n to m
<ESC>
:10,100s/^/#/
(that reads, from line 10 to 100 substitute line start (^) with a # sign.)
and un comment with
<ESC>
:10,100s/^#//
(that reads, from line 10 to 100 substitute line start (^) followed by # with noting //.)
vi is almost universal anywhere where there is /bin/sh.
Use : ' to open and ' to close.
For example:
: '
This is a
very neat comment
in bash
'
This is from Vegas's example found here
You can use:
if [ 1 -eq 0 ]; then
echo "The code that you want commented out goes here."
echo "This echo statement will not be called."
fi
The following should work for sh,bash, ksh and zsh.
The blocks of code to be commented can be put inside BEGINCOMMENT and ENDCOMMENT:
[ -z $BASH ] || shopt -s expand_aliases
alias BEGINCOMMENT="if [ ]; then"
alias ENDCOMMENT="fi"
BEGINCOMMENT
echo "This line appears in a commented block"
echo "And this one too!"
ENDCOMMENT
echo "This is outside the commented block"
Executing the above code would result in:
This is outside the commented block
In order to uncomment the code blocks thus commented, say
alias BEGINCOMMENT="if : ; then"
instead of
alias BEGINCOMMENT="if [ ]; then"
in the example above.
if you can dodge the single quotes:
__='
blah blah comment.
'
In Vim:
go to first line of block you want to comment
shift-V (enter visual mode), up down highlight lines in block
execute the following on selection :s/^/#/
the command will look like this:
:'<,'>s/^/#
hit enter
e.g.
shift-V
jjj
:s/^/#
<enter>
You could use Vi/Vim's Visual Block mode which is designed for stuff like this:
Ctrl-V
Highlight first element in rows you want commented
Shift-i
#
esc
Uncomment would be:
Ctrl-V
Highlight #'s
d
l
This is vi's interactive way of doing this sort of thing rather than counting or reading line numbers.
Lastly, in Gvim you use ctrl-q to get into Visual Block mode rather than ctrl-v (because that's the shortcut for paste).
In all honesty, why so much overengineering...
I consider it really a bad practice to write active code for generating passive code.
My solution: most editors have block select mode. Just use it to add # to all lines you want to comment out.
What's the big deal...
Notepad example:
To create: Alt - mousedrag down, press #.
To delete: Alt-mousedrag down, shift-right arrow, delete.
A variation on the here-doc trick in the accepted answer by sunny256 is to use the Perl keywords for comments. If your comments are actually some sort of documentation, you can then start using the Perl syntax inside the commented block, which allows you to print it out nicely formatted, convert it to a man-page, etc.
As far as the shell is concerned, you only need to replace 'END' with '=cut'.
echo "before comment"
: <<'=cut'
=pod
=head1 NAME
podtest.sh - Example shell script with embedded POD documentation
etc.
=cut
echo "after comment"
(Found on "Embedding documentation in shell script")
You can put the code to comment inside a function. A good thing about this is you can "uncomment" by calling the function just after the definition.
Unless you plan to "uncomment" by calling the function, the text inside the function does not have to be syntactically correct.
ignored() {
echo this is comment
echo another line of comment
}
Many GUI editors will allow you to select a block of text, and press "{" to automatically put braces around the selected block of code.
Let's combine the best of all of these ideas and suggestions.
alias _CommentBegin_=": <<'_CommentEnd_'"
as has been said, the single quote is very important, in that without them
$(commandName) and ${varName} would get evaluated.
You would use it as:
_CommentBegin_
echo "bash code"
or
none code can be in here
_CommentEnd_
The alias makes the usage more obvious and better looking.
I like a single line open and close:
if [ ]; then ##
...
...
fi; ##
The '##' helps me easily find the start and end to the block comment. I can stick a number after the '##' if I've got a bunch of them. To turn off the comment, I just stick a '1' in the '[ ]'. I also avoid some issues I've had with single-quotes in the commented block.
Another mode is:
If your editor HAS NO BLOCK comment option,
Open a second instance of the editor (for example File=>New File...)
From THE PREVIOUS file you are working on, select ONLY THE PART YOU WANT COMMENT
Copy and paste it in the window of the new temporary file...
Open the Edit menu, select REPLACE and input as string to be replaced '\n'
input as replace string: '\n#'
press the button 'replace ALL'
DONE
it WORKS with ANY editor
In vscode ctrl+K+C (ctrl+K+U to uncomment).

Resources