I know PhpStorm allows the option to remove spaces at the end of a line.
Is it possible to configure it to remove tabs or spaces on empty lines?
Example: I type the following
if (1 == 1) {
Then I press enter twice, and I continue coding...
if (1 == 1) {
savePlanet();
The empty line in the middle now has spaces, but I want just an empty line.
You have 2 options here:
Settings | Editor | General, Strip trailing spaces on Save -
when it's set to All, all trailing spaces/tabs are removed on
Save, including the ones on empty lines
Settings | Editor | Code
Style | <Your language> | Tabs and Indents, Keep indents on empty
lines: when disabled, spaces/tabs on empty lines are removed on
code reformatting
Related
I have csv file where each record is one line. Problem is that sometimes one cell have few lines. For example:
first;second;third;something something something something;four
first;second;third;something
something
something something;four
I opened this in Notepad++ and i see that end of record has LF white tag and new lines in cell has CR white tag.
How can I remove this CR white tags? I would like to have after convert:
first;second;third;something something something something;four
first;second;third;something something something something;four
Answer 1: Provided you can uniquely identify where you want to remove the newline
Find: “(Pattern 1 at end of line)\r\n” - Replace with “\1”
Or Find: “(Pattern 1 at end of line)\r\n(Pattern 2 at start of next line)\” - Replace with “\1\2”
Answer 2: Instead if you can identify where you want to keep the newlines
Find: “(Pattern 1 at end of line)” – Replace with “\1QAZ” where “QAZ” is not anywhere in the file. Continue until "QAZ" is everywhere you require
Remove all new lines by Find “\r\n” – Replace with nothing.
Restore required new lines by Find “QAZ” – replace with “\n” – windows Notepad++ does not need the \r
Due to a new coding style that I've been having to use I'm required to use tabs in the beginning of lines but spaces everywhere else to align things.
Is there a way to customize notepad++ to only replace tabs with spaces if it's not at the beginning of a new line?
Just as an example of what I mean I'll use this bit of 'code':
function someFunction():
while(true):
veryLongCodeStuff() // Some comment
shortCode() // Aligned comment
Which I would have to write like this (where \t = tab and a "." represents a space):
function someFunction():
\twhile(true):
\t\tveryLongCodeStuff()..// Some comment
\t\tshortCode()..........// Aligned comment
To convert existing files, I would suggest a two step approach:
replace all tabs with spaces (this can be done with Edit -> Blank operations -> TAB to Space )
replace spaces at the beginning of lines: do a regular expression find/replace like this:
Open Replace Dialog
Find What: ^([\t]?)( ){4} instead of 4 use the number of spaces you have configured as tab width
Replace With: \1\t
check regular expression
click Replace All: as each Replace All replaces only one indent level for all lines: repeat until the status bar of the find dialog tells you, that no more replacements were done (just keep Alt-A pressed for a second or two)
It happens many times when we need to remove line end and unnecessary space between the HTML element. So this could be proven as a time-saving technique.
open Search and replace (CTRL+H)
enable "Regular Expression" (circled in red)
enter \n\s+ in the search field, clear the replace field
press "Replace all"
This will remove all newlines (\n+) followed by all whitespace (\s+) in the next line.
In your Sublime Text user settings, you can specify the following to trim trailing white space.
"trim_trailing_white_space_on_save": true
You might want to have a look at the Trimmer that has a couple of options to trim whitespace.
you can also use \n+ to remove all the unwanted space , if you want to use a single line then replace with \n online
I want to have an empty lines between sections, comments and tags. I'm using jade to output my html and can't output empty lines. Here is what I want.
<div>
<div class='another'>
</div>
</div>
<div>
I want a line just like above
</div>
These are couple of options that worked for me:
The = operator (which enters an evaluated piece of code) with the string for newline character '\n'
div
div.another
= '\n'
div I want a line...
The | pipe operator (which enters plain text) with a space. (had to be two of them for some reason..
div
div.another
| // < followed by blank spaces
|
div I want a line...
Use #{}-style interpolation to generate the empty string:
| foo
| #{''}
| bar
(tweaked lightly from a suggestion in https://github.com/jadejs/jade/issues/912)
The following should give you the HTML output you have asked for:
div
div.another
div
| I want a line just like above
I have some leagacy reporting data which is accessed from SSRS via an xml web service data source. The service returns one big field containing formatted plain text.
I've been able to preserve white space in the output by replacing space chars with a non-breaking space, however, when exporting to PDF leading white space is not preserved on lines that do not begin with a visible character. So a report that should render like this:
Report Title
Name Sales
Bob 100.00
Wendy 199.50
Is rendered like this:
Report Title (leading white space stripped on this line)
Name Sales (intra-line white space is preserved)
Bob 100.00
Wendy 199.50
I've not been able to find any solution other than prefixing each line with a character which I really don't want to do.
Using SQL 2005 SP3
I googled and googled the answer to this question. Many answers included changing spaces to Chr(20) or Chr(160). I found a simple solution that seems to work.
If your leading spaces come from a tab stop replace "/t" with actual spaces, 5 or so
string newString = oldString.Replace("/t"," ")
In the expression field for the textbox I found that simply adding a null "Chr(0)" at the beginning of the string preserves the leading spaces.
Example:
=Chr(0) & "My Text"
Have you tried non-breaking spaces of the ASCII variety?
=Replace(Fields!Report.Value, " ", chr(160))
I use chr(160) to keep phone numbers together (12 345 6789). In your case you may want to only replace leading spaces.
You can use padding property of the textbox containing the text. Padding on the left can be increased to add space that does not get stripped on output.
I have used this work around:
In the Textbox properties select the alignment tab.
In the Padding option section edit the right or left padding(wherever you need to add space).
If you need to conditionally indent the text you can use the expression as well.