removing line numbers for copied code in eclipse - eclipse

I am wondering if I have some code with line numbers embedded,
1 int a;
2 MyC b;
3 YourC c;
etc., and then I copy them and try to paste them in Eclipse, how to get rid of these line numbers to make the source code valid? Is there any convenient way, or a short-cut key?
Thank you.

Simply use the Alt+Shift+A (Eclipse 3.5 M5 and above) shortcut to toggle block selection mode. Then select the column with line numbers and delete it!
To make it easier you could setup a macro, but for that you need additional plug-in. I'm not aware of how to do it even easier.

Try this link. This is a dynamic online tool, where it is very easy to just copy paste code and get code without line numbers:
http://remove-line-numbers.ruurtjan.com/

You could use some script to do the work. For instance, using sed

I removed line numbers by find and replace with regular expression option.
Replacing regular expression \d+\s\s with empty string where \d+ means any combination of numbers and \s is actually a space (This is to avoid any numbers present in the code).

Best way is use SED command. Here you can specify as many as digit you want to replace.
in below example open copied code in VI editor and assuming its containing upto 1000 lines.
:%s/^[0-9][0-9|10-99|100-999]//g
if you want to use more lines then put one more or condition.

Related

Can't Delete File On Terminal

Please, open File 1 to access the problem. If I type it here some important characters that I believe to be what's causing the drama won't show on the post. Thank you!
I basically created a file that I can't get rid of.
Screen shoot of what I have done
Space, <, and > are all treated specially by your shell.
Because of that, you'll need to quote the name. Try this:
rm 'index.html <RET>'
In cases where you can't figure out how to quote/escape the filename appropriately, a convenient approach is:
rm -i index.html*
You will be prompted (because of the -i option) to delete each filename matching the specified glob pattern, one at a time. Simply answer y to the ones you want to delete.
Quoting the arguments correctly is safest (it avoids any possibility of accidentally deleting something you didn't mean to delete), so I recommend always doing so when you can; but if you've managed to generate a really garbled filename (Unix places very few constraints upon filenames) then this method can be very useful.

Error when making .bat file to open programs? scripting

****so this is how the bat file program look like and the error code i am geting ( click the drop box link/copy and paste to browser)****
https://www.dropbox.com/sh/6o4h666m0bwav69/AACTAbDe4jhyWdApEQOoAl7Na?dl=0
only program that is coming up is hitmanpro, every others get error
First of all, paste your code and error directly into your questions in the future.
Now then, the issue comes from the incorrect quotes being used. See how the first three pairs are kinda curly and the last ones are straight? Batch can't recognize curly quotes, probably because it's some Unicode thing. Always use straight quotes in batch. It's best if you code in notepad or a similar program; some text editors make the quotes curly automatically and call them "smart quotes."

diff ignore certain pattern in the file

I want to make diff between two files which contains lines beginning with "line_$NR". I want to make diff between the files making abstraction of the presence of "lines_$NR" but when the differences are printed I want lines_$NR to be displayed.
It is possible to do that?
Thanks.
I believe in this case, you have to preprocess your iput files to remove /^line_[0-9]*/, diff the resulting files, then recombine the diff output with the removed words according to line numbers in diff output.
Python's difflib should be very handy here, or same from perl. If you want to stick to shell, I suppose you could get by with awk.
If you don't need exact output, perhaps you can use diff's --line-format=... directive to inject actual line number in a diff, rather than the word you removed in preprocessing step.

Using boost::program_options

In my program I have a list of pairs - name and size.
I want to build this list from the command line interface using boost::program_options.
It should look something like this:
myProg --value("John",10) --value("Steve",14) --value("Marge",28)
I also need this to be in order - Steve will be after John and before Marge on the list. Is that possible with boost::program_options?
This CLI syntax is just an idea to get the list. If you have a better one, do tell.
You just define your option
("value", value<vector<YourPairType>>()->composing(), "description")
and an appropriate
istream& operator >> (istream& in, YourPairType& pr) { /* ... */ }
that reads a single YourPairType from in in your ("John",10) format. Parsed options will be stored in the order they appear in the command line.
You can achieve greater flexibility if you use custom validators instead of operator >>.
A file with each line having one pair of values can be one option. The file could be a plain ascii text file or you can go for xml files too - refer to boost serialization.

Getting output on the same line of a file in DOS?

If I have output from two sources that I want to put together on the same line, how would I do that?
In my case I have a file and a program. The file is something like this:
listOfThings=
My program outputs a list of strings on a single line. I want have a small script that runs nightly to put these two things together on a single line. I can't figure out how to do this right though
example batch file
type header.txt > outputfile.txt
myProgram >> outputfile.txt
which results in this:
listOfThings=
foo bar baz etc
I really need the output file to have the list immediately follow the =, but I can't figure out how to do it with the >> operator. (and before anyone suggests it, I can't do something like put a \ on the end of the listOfThings= line, that won't work for what I'm trying to do)
You need to make sure that the contents of header.txt does not have a carriage return linefeed pair in it. Look at it with a hex editor and make sure there is no 0x0d0a in it.
Have you made sure that header.txt doesn't have any line separators in it at all? (Ie, the = is the very last byte of the file).
Also, try copying header.txt to outputfile.txt in case type is appending a line feed on it's own.