VS2019 copy and paste changes tabs to spaces - formatting

I've just upgraded from VS2012 to VS2019. I have the tabs set up in Options|TextEditor|C#|Tabs as Smart, Tab Size 4, Indent Size 4, Keep Tabs (as OOTB). I have the same set in All Languages, except that it refuses to set Smart Indenting (which may or may not be relevant to the problem).
The problem is that if I copy and paste the following line in a .CS file:
private bool myPrivateField1; // Private fields should be PascalCase
the indenting is fine, but the tabs between the code and the comment get replaced by spaces in both the copied line and the pasted line. 2012 doesn't do this and it's really annoying.

try to deactive adaptive formatting. Tools->Options->Text Editor->Advanced than uncheck [Use Adaptive Formatting]

Related

How to paste multiline text in pycharm?

Everytime i try to copy and paste something on my Pycharm editor it all paste it in single line. How to automatically paste in multiline?[1]
This is what i copied.....
[{"DateObserved":"2020-06-12 ","HourObserved":23,"LocalTimeZone":"EST","ReportingArea":"Central New York Region","StateCode":"NY","Latitude":42.8049,"Longitude":-76.3589,"ParameterName":"O3","AQI":35,"Category":{"Number":1,"Name":"Good"}},{"DateObserved":"2020-06-12 ","HourObserved":23,"LocalTimeZone":"EST","ReportingArea":"Central New York Region","StateCode":"NY","Latitude":42.8049,"Longitude":-76.3589,"ParameterName":"PM2.5","AQI":0,"Category":{"Number":1,"Name":"Good"}}]
and this all got pasted in a single line on my Pycharm editor. can anybody help with that, its pretty hard to read all this info on a single line?
It seems like you didn't copy anything containing newlines as you can see better after my edit (See the side-by-side-markdown diff so you can see that I didn't remove any line breaks).
If you just copy everything as a single line, PyCharm won't be able to split it into multiple lines (except with auto-format maybe).
As you haven't said how you copied the input, I can't say what exactly is wrong.
However, it seems like you copied something from a program that didn't display the text correctly so that you couldn't copy it correctly.
Another possibility is that the IDE interprets line breaks differently.
For example, windows uses CRLF(carriage return+line feed) as a line seperator while linux uses LF only.
If your file contains only LF line breaks and PyCharm is configured to use CRLF like breaks, it is possible that it ignores them because of that.
You can change that behaviour at the bottom of your file in PyCharm (button with CR/CRLF/LF).

How to copy code from vscode to OneNote without losing the formatting?

I want to keep a record of code I am working on by saving it in MicroSoft Office OneNote. When I copy and paste the code, all the indentations are gone.
def primeGenerator(primeList1, arr):
for i in range(2, len(arr)):
if arr[i]==0:
primeList1.append(i)
for j in range(i**2, len(arr), i):
arr[j] = 1
Code shown above becomes like this
def primeGenerator(primeList1, arr):
for i in range(2, len(arr)):
if arr[i]==0:
primeList1.append(i)
for j in range(i**2, len(arr), i):
arr[j] = 1
I tried the solutions I found on the internet like
convert indentations to tabs in vscode
copy the code first in MS Word then in OneNote.
It isn't supported natively, however there are open source workarounds such as:
https://github.com/elvirbrk/NoteHighlight2016
There is a OneNote Settings/Options/Paste Options/
Make sure that is set to Keep Source Formatting.
My pastes into OneNote retain indentation and syntax highlighting (I have Editor: Copy with Syntax Highlighting enabled).
I would advise against using Keep Source Formatting in OneNote under Settings. I just notice that when Copying from Visual Studio Code into OneNote, OneNote replaces all space charactes (0x20) with NonBreak Space (0xA0).
To recreate the problem, copy something from VSC, and paste it here. Then Paste it into OneNote. Then copy from OneNote, and paste it back in that same link. You will see that all the spaces (0x20) has been turn into NonBreak Space (0xA0), which Visual Studio Code does not like (CSS, JS, etc).
Instead use Keep Text Only
On Windows
in VS Code change the settings Editor: Insert Spaces to checked.
before copying JS code from VS Code to OneNote find replace using
regex:
Find: \n\n
replace: \n\n\n
replace all.
Cut and paste into OneNote.
Seems to be a bug in the copy paste of LF / CRLF defined text to OneNote.

Mysterious Black Lines in Word When Using In-House VB.Net Application

A little backstory. I work at an organization that uses Mail Merge and SQL Databases to populate letters with names/addresses. Those letters are sent out to our donors as thank yous. These letters change frequently, and new ones come up at least 10 times a month.
To simplify our process, I created a program that allows you to copy/paste the letter body content into rich text boxes and when you press the 'Go' button, it opens a pre-made Word template and replaces bookmarks in the template with the copied body content.
The program works great with most letters, but some of them have a problem where these thick black lines are created and I'm unable to do ANYTHING to remove them. I can't right click them, I can't delete them with Backspace or Delete, and I can't highlight them.
I'm thinking that the problem may come from hidden formatting. Some of the employees that write the letters are using the Mac version of Office 2016, and I'm using Windows version. I sent an RTF file that showed the black lines for me to someone who uses the Mac version, and they said they couldn't see the lines.
My question is, is there a way to get rid of these lines or prevent them in the future? I've thought about upgrading Office version to 2019 on both ends, but there are quite a few people that have their hands in these letters and it may be difficult to upgrade everyone.
Please refer to the attached image for visual reference. Names and personal details have been removed.
EDIT: Here is the 'Go' code:
'create temp rtf files to maintain rtf
If strForm = "ANG2" Then
txtPreD.SaveFile("\\server\AcknowledgementLetters\fptemp.rtf")
txtPostD.SaveFile("\\server\AcknowledgementLetters\bptemp.rtf")
ElseIf strForm = "ANGL" Then
txtPreD.SaveFile("\\server\AcknowledgementLetters\predtemp.rtf")
txtPostD.SaveFile("\\server\AcknowledgementLetters\postdtemp.rtf")
txtBP.SaveFile("\\server\AcknowledgementLetters\bptemp.rtf")
Else
txtPreD.SaveFile("\\server\AcknowledgementLetters\predtemp.rtf")
txtPostD.SaveFile("\\server\AcknowledgementLetters\postdtemp.rtf")
End If
'if bookmarks exists, insert appropriate rtf files
If odoc.Bookmarks.Exists("fp") = True Then
goWord.ActiveDocument.Bookmarks("fp").Select()
goWord.Selection.InsertFile(FileName:="\\server\AcknowledgementLetters\fptemp.rtf")
End If
If odoc.Bookmarks.Exists("bp") = True Then
goWord.ActiveDocument.Bookmarks("bp").Select()
goWord.Selection.InsertFile(FileName:="\\server\AcknowledgementLetters\bptemp.rtf")
End If
If odoc.Bookmarks.Exists("PreD") = True Then
goWord.ActiveDocument.Bookmarks("PreD").Select()
goWord.Selection.InsertFile(FileName:="\\server\AcknowledgementLetters\predtemp.rtf")
End If
If odoc.Bookmarks.Exists("PostD") = True Then
goWord.ActiveDocument.Bookmarks("PostD").Select()
goWord.Selection.InsertFile(FileName:="\\server\AcknowledgementLetters\postdtemp.rtf")
End If
Before this happens, the program checks to see which template it needs to open and opens it as a Word object (odoc). This bit of code is really the only important part. After this, I just click Finish it just saves the file once I'm done checking it for errors. Also, yes, the RTF files that it creates DO have the black lines as well. Here is another picture of the program itself just so you can get a better idea of what's going on.

How to preserve spaces in the Visual Editor of WordPress?

My client is trying to be able to copy and paste formatting from a Word document into WordPress and have the spacing be preserved (he is copying/pasting a poem written by a 3rd party). The Visual Editor in WordPress is removing the spaces by default. How can I get the spacing to stay? I need to make sure my client is able to copy and paste his text from Word into the Visual Editor because he does not know code. I've tried the following, but it hasn't worked:
I've tried adding this to the functions:
function allow_nbsp_in_tinymce( $mceInit ) {
$mceInit['entities'] = '160,nbsp,38,amp,60,lt,62,gt';
return $mceInit;
}
add_filter( 'tiny_mce_before_init', 'allow_nbsp_in_tinymce' );
If there was something like this, but instead of removing the spaces, it preserved them, that would be good: https://wordpress.org/plugins/space-remover/#reviews
Any ideas?

Intellij IDEA 14 - remove indents on empty lines

I have an annoying bug regarding intellij 14.0.3. The issue is that it keeps indents on empty lines and I can't remove that whitespace in any way. Under code style, I have not checked the checkbox "keep indents on empty lines" and judging from the display how that functionality works I'd say it would do it.
However, it still keeps the indents and that creates bad diffs in git since whitespace is added. Is this a bug? Can I in any way remove them? I have tried to uncheck that checkbox under both the language I use and the main one. None of them seems to change it.
Try enabling the Strip trailing spaces on save option in Settings/Editor/General.
You can choose whether this should be performed for All lines or only the lines you modify to avoid creating unnecessary diffs.
The whitespace is stripped when you explicitly hit CTRL+S or automatically after some period (IntelliJ has autosaving).
One thing to note is that if you have cursor on an empty line and there are some spaces before it, hitting CTRL + S won't strip the whitespace, because this would probably be annoying as your cursor would jump to the beginning of the line if the file was autosaved by IntelliJ (I read somewhere on YouTrack that this was a design decision).
Here is a screenshot of the option I describe:
What I did to strip spaces without having to open & save each file is running a regex in the find and replace window:
Ctrl+Shift+R
Text to find ^ +\n Find every line that starts with (^) one or more spaces ( +) and nothing else (/n).
Replace with: \n A new line.
General > Regular expression (obviously important to check this box)
Eventually you may want to limit the scope because this will be quite the lengthy operation
Find and eventually continue if IDEA warns for the high amount of occurrences.
Click All Files to run the actual replace operation. It might take some time before IDEA to respond.