How to paste text with links and formatting into VS Code like Obsidian? - visual-studio-code

If I copy the above text from Chrome and paste it into Obsidian, I get
People who code: we want your input. [Take the Survey](https://stackoverflow.com/dev-survey/start?utm_source=so-owned&utm_medium=announcement-banner&utm_campaign=dev-survey-2021)
[](https://stackoverflow.com/questions/ask# "dismiss")
But when I paste into VS Code or any other editor, I get
People who code: we want your input. Take the Survey
Video Reference: https://dsc.cloud/J/67968285.mov
How does Obsidian do it? How can I achieve the same in VS Code?

— — — — — — — — — — — — — — — — — — — — — — — — —
The Short Answer:
"        The VSCode editor does not support the feature you described, and VSCode will almost certainly never support any functionality that comes close to it. This is because of what VSCode is, and what VSCode does, which I will explain in detail below."
The Long Answer:
So VS-Code is a text-based editor, and its purpose is to be an environment that programmers can write their code in, therefore, people using VSCode are going to preform a long list of tasks which includes, but is not limited to:
interpret, compile, execute, debug, serve, share, save, write, read, document, and run code. Now here is the problem with adding the ability to paste arbitrary data types into VSCode. Having any type of data, other than standard text in a file that you plan on using to do one of the following (this is the very short list)...
compile,
execute,
debug,
interpret
parse,
serve,
...will cause a syntax error to be thrown.
When you can copy, and paste, text-formatting from an external source (like a webpage), there is an extremely high probability that some unwanted formatting data will get pasted into some program you've written, and the text's format-data will end up not rendering for what ever reason (theirs a million and 87 reasons why that would happen), and you end up getting syntax errors that you can't see, so you now have no idea where the error is, despite the error message saying line number 734 column 24. In a situation like this you will have an error message that makes no sense, and you will have to start deleting things to find the issue. all because it has text-formatting data intertwined with standard text-data, which you can't see. I hope I drew a clear enough picture for you.
Their are other tools called word processors that implement this feature. I constantly couple G-Docs with VSCode.
Crazy Enough, not all is lost
VSCode allows extensions to make custom editors. The Extension API used to create an editor (can be seen by clicking the link) lets developers build the UI using standard HTML, CSS, and JavaScript. This is enough for someone to write a Word Processor for VSCode, which surprisingly no one has done yet. When someone does create one, which I am almost certain that someone will eventually, in could support the feature your asking for.
For the record, the feature your describing is typically a word processor thing. VSCode allows you to install extensions such as PASTE, which copies and pastes other data types, however; when it is pasted into the editor, instead of rendering the data types like HTML, it just writes it in its text format. In other words, you might think your copying the page at first, but you will be disappointed once you paste to VSCode. I want to point out that Paste uses the GTK-3 Clipboards API, which means that if Paste were to be implemented in a word-processor, like word, or Google docs, those word processors would render the data the the Paste extension pasted into the word processor. In other words, it isn't the extension that is failing to render the Data (which as stated, can be done with the Paste Extension), but its VSCode that wonder render that data as HTML, but only accepts it as a standard text data type.
#W3Dojo

What you've copied can be considered "rich text", but VSCode treats everything in your clipboard as plain text.
So it's the same as pasting via "Ctrl+Shift+V" in other programs like Word or Google Docs. It will remove any formatting, links, color, font, bold/italic, etc.
Obsidian was built with formatting in mind - it closely follows the markdown specification, so it's natural that it will try to convert any rich text to markdown.
I'm not aware of a built-in VSCode setting that will allow you to paste rich text, but I've found 2 extensions that might do the trick:
Paste Special
Markdown Paste

Related

Getting github to syntax highlight my files

github automaticall syntax highlights any code files such as those with .c extensions. And there seems plenty of information about controlling highlighting from within 'markdown' or .md files.
But how can I get it to highlight code files that it doesn't know about?
I can't even get the tabbing right - if I say 4-spaces tabs while editing, it goes back to 8-space ones when I've finished.
I don't care what highlighting style it uses even if it's the wrong language; it must be better than the plain text appearance which looks really flat. Oddly, when editing it uses some sort of highlighting, which again disappears when I've finished.
The files aren't in any well-known language so the highlighting won't be perfect; I just want a bit of colour. But I'd rather not change file extensions as that could be confusing.
The tabbing is done through a ?t=4 parameter added to the GitHub url.
But the syntax highlighting (using Rouge on GitHub pages for instance) itself is either:
set in fenced code block (but only for .md markdown pages)
or by changing the file extension (which you don't want)
But how can I get it to highlight code files that it doesn't know about?
Update Feb. 2021 (5 years later)
Nat Friedman (CEO of GitHub) announces it on Twitter:
Another tiny but nice improvement we just shipped to GitHub – syntax highlighting now works on new files without the need to commit first.

Auto update changed paths like Dreamweaver, Possible in Sublime Text?

I recently started using Sublime Text 3, mostly for HTML and CSS and still learning the tricks.
In Dreamweaver, if I change a linked file/folder name or move it to different folder (within the project folder), it asks if all the html file containing those links should be updated and if confirmed it does updated the all the files in the project folder automatically, even the unopened files are updated! It saves a lot of time and errors.
This is the only feature I missed in Notepad++ when I used it for few projects.
Now, I am wondering if the above feature is there in Sublime Text (by default or with the help of some plug ins)?
I will greatly appreciate any helpful suggestion.
This feature is not present in Sublime by default, nor in any plugins of which I am aware, and although it is theoretically possible to write such a plugin it would be quite computationally intensive to have the feature "live". I find it much easier to keep CSS, JS, and markup in defined directories, and not move them around after creating them :)
You have to keep in mind that Notepad++ and Sublime Text are text editors, not IDEs, and so don't have all of the features of giant programs like Dreamweaver that are hundreds of times their size. Their primary purpose is editing and otherwise manipulating text, and ST at least (I'm not terribly familiar with N++) has a nice plugin API for writing functions to assist with that (such as inserting the path to a file), and people have even been able to write much more complex plugins to do things like linting and code intelligence, but things like keeping an eye on large groups of files and changing them all in response to certain events, or completely refactoring significant amounts of code, just isn't what it's designed for.

How to efficiently edit Markdown in the github issue tracker?

I like the fact that the github issue tracker supports Markdown. However, I find it relatively unpleasant to actually write Markdown in the github editor. It lacks many of the features of the Markdown editor on StackOverflow.
E.g., it lacks:
a button to indent multiple lines of code by four spaces
a button to add quote to the start of each line
real time markdown preview
fixed width font
ability to insert image using imgur
a confirmation dialog box when you close a browser window when you might otherwise lose your work
In particular, the inability to insert code blocks is probably the feature I miss the most.
Sure, I could write my markdown in a separate editor and then paste it into the github issue tracker, but this is not especially appealing. I could even use the StackOverflow editor if I was careful not to click "Ask Question", but that seems a bit silly.
Question
Is there anyway of altering the text box in github to incorporate the editing features in StackOverflow?
Or if it is better to type in another text editor, what's a particularly elegant way of doing that? (e.g., minimum steps, simple to move back and forward, good editor) Perhaps theres a way of clicking a text box and bringing up a Rich Markdown editor which when closed returns the contents to the original text box?
You should appeal to GitHub to add one. Your argument is sound. Stack Overflow demonstrates editors can be functional, non-intrusive and tasteful.
Meanwhile, there might be a browser extension that does some of this. https://chrome.google.com/webstore/detail/cpojebknccclkjabfngjlcknonpmhhol
If you are on Windows, you might want to check MarkPad: http://code52.org/DownmarkerWPF/
Disclaimer: I have never used it myself (being on Ubuntu), only read about it watching the code52 project. I know it can edit posts of several blog systems, but I'm not sure if Github is in the list of supported web sources. Its syntax however is supported, for sure.

Is there a code editor that will allow copying of syntax highlighting to an Office Document for Windows?

Is there a code editor that will allow copying of syntax highlighting to an Office Document for Windows?
I want to be able to copy code into a Word doc or EMail and preserve the Formatting when explaing code changes.
I will need support for multiple languages including C, C++, TCL, Javascript, Basic, and couple others.
The ability to include the line numbers for reference purposes would be a nice additional feature. I had one customer that required all code to be submitted with line numbers in a Word or PDF document.
I used Notepad++ in the past. It has a plug-in called NppExport and I think it has everything you need. The catch is that you have to write/open your source files with Notepad++, then export them to rtf, open the rtf and copy the pretty-formatted text to your doc file.
Here is the link to Notepad++ and to a good article to get you started with NppExport plugin.
Visual Studio (2010 Professional) "works fine" for copying code and formatting/coloring to MS Word (2010) and Outlook (2010)*. It supports at least C/C++/C#, and JavaScript code. It might support TCL/BASIC (it does support VB/VB.NET), but I do not use those languages. And, of course, VS is a full-blown IDE.
Visual Studio 2010 Express is free (as in beer). But as my company pays for my copy, I can only hope the copy'n'paste support works in Express as well ;-) In any case, it might be worth a try.
I am not sure if line-numbers can be exported via copy'n'paste, but I sort of doubt it. It's not a use-case I've run into.
Personally, I'd recommend doing the review via a SCM/code-review process and not manually, which just sounds like a nightmare. There are additional advantages of using tooling designed for this purpose including history management and talking about what really is, or could be (in relation to what was), and not a copy of what might have been.
Happy coding.
*After pasting into Microsoft Word, disable the "Add space after every paragraph" option to remove what appears to be blank lines from the pasted code.
Eclipse will do fine if you install the language support for all the wanted languages.

Looking for a Document Comparer that can generate difference reports

I've been using an application called "WinMerge" lately for document comparisons, but one of the requirements of my teams script files (for auditing purposes) is that when we release a revision of a script we highlight the changes in red (RTF format I believe, it's through Lotus Notes) To that end, is there any software that can automatically highlight changes for me or is the best I'm going to get a list of differences and be expected to manually highlight all changes?
Assuming an HTML+CSS solution meets your needs, this article from Linux Journal shows a shell script that reads diff output and writes an HTML document with colored text highlighting the differences.
On Windows, it would probably work as-is under bash as provided in the MSYS environment from the MinGW folk or in bash from Cygwin. The script itself isn't too large, I would imagine it could be ported to Perl with only a moderate effort.
Since converting HTML to RTF turns out not to have a trivial solution that I've found, you might have better luck porting the script to directly output RTF.
If an HTML report is acceptable, Beyond Compare can generate a comparison report that highlights differences. You can use the built-in stylesheets or a custom internal one to style the differences in red (the default is a light red color already).
It doesn't seem to be able to generate RTF, but perhaps there is a simple conversion between html/css and rtf.