Remove trailing whitespace automatically on save in Clion 2017 - c++

So there is already a post on how to remove trailing whitespace for IntelliJ, but there are claymores invisible to the naked eye as usual:
Remove trailing whitespace on save in Intellij Idea (12)
However, there is a C++/C editor derivative of IntelliJ, which is called Clion, and unfortunately no such checkbox exists as in the same location as in the link. So I can't use a mine detector.
I can't find anywhere in the internet how to automatically remove trailing whitespace on save in Cion. If anyone knows where the setting is, please let me know. Thanks, and call me Mr. X.

It's under File -> Settings -> Editor -> General -> Other:

Related

How to find non localised strings in a swift project

How can I find all strings a project that are not being localised?
My goal is to add support for localisation by generating the XLIFF file, via Editor->Export For Localisation. In order to do that, I first added comment for Localiser where needed in the Storyboard.
Next, I need to find in the code all Strings that do not use NSLocalizedString("...", comment:"...").
Is there a way to find all these strings?
I didn't succeed writing a regex to find them, due to my lack of competence in regex.
My goal is to have a regex like this:
[withIdentifier: |NSLocalizedString(]".*"
in order to find all strings surrounded by quotes, and that are not precedeed by some keywords.
I tried with no success using negative look ahead with
A regular expression to exclude a word/string
It's not meant for automated replacement, but just to have a quick view if I haven't forgotten some strings.
Thank you very much!
OBJC
There is a possible way that you can find ALL The Strings which are not used by NSLocalizedString
Goto Product -> Analyze
From Left Panel you can see
Where you can find each and every string which are not Localized
On tap on that
XCode will tell you issue
SWIFT3
I am not Sure about solution NOT TESTED
https://medium.com/#pinmadhon/finding-non-nslocalized-strings-in-xcode-8-in-swift-3-or-objc-589ee279a166

Sitecore Forward Search generates wrong URLs

I'm using Sitecore Forward Search. Currently I've added a replace into web.config file to replace spaces in item names from one character to another. And now, in item URLs, spaces are replaced by one character and forward search still generates links with another character. How to fix this problem? I've tried to re-index Search index, but it still the same. I appreciate any help you can provide.
First, I would recommend going back to a standard hyphen rather than an em dash. Em dash is a non-standard character. Very few users would even realize the difference between that and a hyphen and even if they did, they wouldn't know how to type it.
Disclaimer aside, if your links are being generated properly when you browse the site, your search engine should be picking them up. Did you just run the indexer or did you do a "Clean re-index"? If it is still not getting the correct URLs after a clean re-index, I would double (or triple) check your configs and then contact Forward Search support.
You might want to try this module I created: SEO-friendly URL module
It implements a custom LinkProvider and ItemResolver that replaces special characters in your URL, one of them being spaces replaced for hyphens (-).
The thing you're doing now is simply replacing spaces for hyphens, but Sitecore is then not able to resolve the items anymore.
Ben is right, a "clean reindex" might do the trick, but it depends on version.
Manual approach:
Delete Index folder(location might depend on configuration)
Delete Storage subfolder(location defaultly as subfolder to ForwardData)
Trigger a full update(Trigger tool or admin client)
At this point Forward Search should index the site in the context of a normal visitor and links should be resolved as such.
Sometimes there are certain navigation elements as breadcrumbs which by mistake generate other/duplicate links; like links with "Sitecore/content" as prefix or a language specification.
This can be circumvented by using canonical or adjusting the exclude pattern.
Best regards
Thomas Jensen, Part of the Forward Search team

Validation of a CQ5 dialog through regex

I have a widget for my dialog, which I would like to validate using a Regex.
Here are its properties:
<widget
regex="/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]#[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/"
regexText="Please enter a valid email address"
xtype="textfield"
fieldLabel="Email"
name="./email"
allowBlank="false"/>
Whenever I input a valid email address, it always returns false. I have admittedly zero prior knowledge on working with regex.
Where am I going wrong?
Try the following regex, this one works for me.
/^[A-za-z0-9]+[\\._]*[A-za-z0-9]*#[A-za-z.-]+[\\.]+[A-Za-z]{2,4}$/
For people with similar issues who are searching this on google:
Open CRXDE and edit the dialog by double-clicking on the dialog icon. It will open a special dialog editor. Select the text field you want to edit and enter the regex in the UI. Enter only a Javascript-valid regex. Find and use a Regex tester on google if you need to, to ensure it is valid. Save the dialog then look at the JCR (remember to refresh CRXDE as it caches old content) or export using package manager.
Some common issues:
Must start and end with "/".
/foobar/
All XML characters need to be escaped. I don't know why, it seems very odd to me.
/Surf&Turf/
/<html>/
Slashes must be escaped with backslash. Backslash must be escaped with backslash. (Just use character classes, it's cleaner anyway).
/http:\\/\\/www\\.google\\.com/
Good luck!
I guess the following should work for you regex:- /^[a-zA-Z][\\w\.-]*[a-zA-Z0-9]#[a-zA-Z0-9][\\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
Here is one that runs in adobe cq5, try it out
/^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*#[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$/

Remove empty lines in eclipse code editor by find/replace (Ctrl+F)

I want to remove all blank lines from my code by find/replace method in eclipse code editor.
I used regular expression \n\s*\n to find all blank lines but got error "Incompatible line delimiter near index 55110" when replacing the blank line with any string.
Why i got this error and how to properly remove the blank lines? What will the working replacement character ?
Is there any eclipse plugin for these kind of job?
I am not sure if it is the answer to your specific problem but the solution with the \r\ .. indicates it is an incompatibility between Windows and UNIX text encoding . So a simple solution will be to convert the file to UNIX encoding
In Eclipse Menu -> File -> Convert line delimiter -> Unix
You can try replacing this:
^\s*\r?\n
with the empty string.
try using \R instead of \n
\R Any Unicode linebreak sequence \u000D\u000A|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029]
I tried your expression, and it combined some lines. I found this one to work:
\n\s*$
with a replacement of [nothing].
Can't help with the mysterious error, though. I wonder if you have a corrupt file, maybe a stray CR/LF confusion.
(As for a plugin... don't know of any, but, well, learn awk, sed, perl... they'll always serve you well for your miscellaneous text-mangling jobs.)
In response to the first part of your question about the incompatible line delimiter near index error, Eclipse seems to have an issue with Replacing the given line delimiter depending on the Text file encoding and New text file line delimiter settings.
I had an issue where a Windows application mistakenly formatted UNIX-formatted source files, inserting CRLF wherever it saw fit. Because of the particular situation I had to replace all of the CRLF's with space. Eclipse wouldn't allow me to do this because of that error, but grabbing the preceding and succeeding characters did the trick:
Find : (.)\r\n(.)
Replace: $1 $2
Using wjans suggested answer:
Find : ^\s*\r?\n(.)
Replace: $1
I hope this helps with those of you still getting the incompatible line delimiter error.
This worked for me for years:
Replace: [\t ]+$
With blank
I've been having this problem (or variations of it) for years and I suspect it's caused by sharing fileservers with Mac users, specifically users of Dreamweaver (graphic artists basically). It looks like it changes the files it edits (uploads?) to mixed/weird line endings that appear to be a combination of NL+CR (hex 0a0d), double-CR (0d0d) and solidary newlines (0a).
If you opened the same file in vim it isn't double-spaced BUT the lines all end with an ^M symbol.
Anyway, none of the solutions on this page worked for me but I found something that does.
You need to perform these steps in order (Eclipse 4.2.2)
1.) File -> Convert Line Delimiters To -> MacOS 9 (CR, \r)
2.) Edit -> Find / Replace (Ctrl - F)
Find: \r$
Replace: leave blank
3.) Replace All
If you don't do it in order or you mess with the file first you'll get an error about "incompatible line delimiters" like in the question.

How can I match the beginning of a line in dreamweaver with regex?

Problem:
^.+ matches only the first line of the source code in dreamweaver. I need it to match each line so that I can wrap each full line in P tags. I have 500 files to do this in.
I know ^ should match the beginning of a line and I also know that multi-line mode must be enabled for it to work on each line and not just at the beginning of the file. I also know dreamweaver uses javascript source code.
Is lack of multi-line mode the problem? Is there any way to turn it on in dreamweaver? I tried using /m at the beginning search to enable multi-line mode, but that didn't work either.
I'm open to any solution for my current problem, even if it involves a different program. However, a fix for dreamweaver is ideal, 2nd place is a way to do this in notepad++, 3rd place is a way do to this in python or something (I only know javascript, you'll have to spell it out exactly in another language).
Thank you,
robert
p.s.
I found I can "select all > right click > selection > indent" to add two spaces to the beginning of each line in dreamweaver. This allows me to find the beginning of each line with / {2,}/. I really don't want to select all > indent on all 500 files, but i'm about to start since I've already spent a few hours bludgeoning dreamweaver.
Don't use Dreamweaver for this - use Notepad++ (since you are familiar with it) at its regular expression support is superior.
If you are comfortable with a more robust scripting language (Python, Ruby, Perl, etc.) then that would be an ever better way to do it.
The way that I might do this in DW would not involve using the find-replace tool's "Regular Expression" option, but instead using just plain old matching on a CrLf.
In the Find portion, since you can't directly enter a CrLf, you'll have to copy one to your clipboard beforehand and paste it in where needed.
In the Replace portion, replace with:
</p>[CrLf]
<p>
Again, be sure to paste in a proper "[CrLf]". This will work on all but the very first and very last lines of your document, so I know this isn't a 100% solution. There are probably better solutions using other tools that someone else can recommend!
Good luck!
-Mike
I had a flash of insight right after posting. (isn't that the way of it?)
Dreamweaver can find the end of each line with \r\n so instead of trying to work forward, i should have just worked backwards.
search: (.+)(\r\n)
replace: <p>$1</p>$2
[\w\W]* matches anything, including a newline. Its greedy, so it fact it matches everything.