I have a method that has has a closing bracket at line 20, I want my next method to start at line 23 because I want line 22 to have a comment. This will leave line 21 to have the one space between these two methods, but because line 22 is a comment SwiftLint will throw a "Trailing Whitespace Violation". Is there any way to fix this?
Trailing whitespace violation doesn't mean that there is an empty line, but rather that there is some unnecessary whitespace (not linebreaks, but tabs/spaces).
You can automatically fix trailing whitespacing by turning on the relevant feature in Xcode. You can find it in Xcode Preferences: Text Editing/Editing/While editing, turn on both "Automatically trim trailing whitespace" and "Including whitespace-only lines".
Related
I upgraded Netbenas 8 to Netbeans 12 and now my diff window does not always highlight added or removed spaces in the code.
It does highlight if spaces was added or removed in the middle of the line (after a non space character), and before a non space character.
But it does not highlight when the space was added or removed form the beginning of the line, or at the end of the line. Preceding and trailing spaces change does not get highlighted.
I tried restarting Betbeans - it did not help.
I checked HTML, PHP, TXT source code, all have the same problem.
Is there any config parameter to fix it, or is it a bug?
Navigate to Tools > Options > Miscellaneous > Diff
By default, the checkbox Ignore Leading and Trailing White Space is checked:
Just uncheck the checkbox, then click the OK button. Diff will then report on leading and trailing space differences.
In Windows 10 I use a text editor (I'd like not to point out a particular one but I usually use Visual Studio Code AKA "VSCODE").
I need a way to delete all blank lines whatsoever only with regex after I matched them with this code:
^\s*$
After I match the lines themselves, how is it possible to delete the lines?
AFAIK, regex only edit lines, not deleting lines or adding lines.
I desire a way to delete all matched (empty).
Hitting "Enter" or "Delete" in the empty "replace" box doesn't delete lines:
You were close. You were missing the new line character in your regex. This worked for me:
^\s*$\n
Without the newline character, you are matching the blank line itself which you then replace with nothing but you've left the newline character so it still leaves an empty line in place.
Using Atom 1.14.3, I have whitespace package that handles auto-inserting newlines at the end of files.
Even if I delete the end newline and hit save, it re-adds the newline. This is good.
Whitespace package configuration seems to be okay:
The problem is, when I commit to Github, it says the newline has been removed:
Why is this? Is it an Atom issue, or a potential local github setting issue?
EDIT: somehow, I needed to disable whitespace package, manually add two CRLF at the end of the file, and then commit for Github to pick up the single CRLF at the end of the file.
I think you might be misunderstanding where the newlines are.
Let's look at your two screenshots, and where the newlines are in each.
233 return router;\n
234 };\n
Here we have 234 as the last line in the file. We have a line 235 displayed, but that is because the newline on 234 creates the next line for your editor cursor to be on. If you started typing on 235, you'd be creating more content. But right now, 235 is an empty line (including having no terminating newline).
233 return router;\n
234 };\n
235 \n
This is similar except it also has an empty line 235 that ends with a newline. Now the newline-less empty input line has moved to 236.
When you saved with the whitespace package active, it removed extraneous newlines at the end of the file, leaving only one. As in the first screenshot. However, when you look at the Github diff, things are little different. Github is showing you the file contents, not in an editor. So there is no reason to have the phantom last line for your cursor. Instead, it shows you the simple truth of the matter: line 234 is the last line in the file. Line 235 is now gone.
Let's take a look at the settings for the whitespace package. Specifically the first setting:
Ensure Single Trailing Newline
If the buffer doesn't end with a newline character when it's saved, then append one. If it ends with more than one newline, remove all but one. To disable/enable for a certain language, use syntax-scoped properties in your config.cson.
Here are the first two sentences of the description again, with some emphasis added:
If the buffer doesn't end with a newline character when it's saved, then append one. If it ends with more than one newline, remove all but one.
The question is as simple as stated in the title - how to remove the whitespace in Eclipse, but only from the selected lines.
There are a lot of answers on SO how to remove trailing whitespace in Eclipse. Most of them focus on automatically removing it on save and all of them concern removing all of the trailing whitespace in the file.
I want none of these, as I am working on large JS files that are awfully formatted and very frequently committed; removing all the trailing whitespaces in the file would easily cause merge conflicts and a lot of noise from the people.
So I want to select specific parts of the files and fix them, in the way that this is possible with Source -> Format (Alt+Shift+F).
Shift-Ctrl-Right arrow will highlight whitespace to the right until next non-whitespace character (which may be newline). Press delete. If you lose the newline, simply press enter.
Right now I'm using:
(setq show-trailing-whitespace t)
In my .emacs to show trailing whitespace for my CC mode. I can't seem to figure out how to have it not show the whitespace font for whitespace only lines.
Empty lines separating indenting code are sometimes indented at the code level and sometimes not indented at all, and I don't want to draw my attention to a line I don't care to change.
I'd like to stick to built-in emacs modules, but I'm willing to use whitespace.el but it's not clear how to configure it to do this.
Since you want to use built-in modules, I'd advise using the whitespace.el link you specified - as it is shipped with Emacs 23. This answer works when using that whitespace.
As long as you have 'trailing in your 'whitespace-style variable (which it is by default), the following change to the regular expression for what indicates "trailing" whitespace should give you what you want:
(setq whitespace-trailing-regexp
"\\b\\(\\(\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)$")
Note: It is just the default value, with the \b prepended, indicating that the whitespace should follow a word.
With
"\\b.*\\(\\(\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)$"
the word does not need to be directly in front of the trailing whitespaces but there can be e.g. punctuation characters between them (i.e. this also highlights trailing whitespaces behind non-word characters).
Edit:
Using
"\\b.*?\\(\\(\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)$")
highlights all the trailing whitespaces and thus eliminates the drawback mentioned in comment #1.