How can I make Vim paste from (and copy to) the system’s clipboard?

TL;DR Try using “*yy or “+yy to copy a line to your system’s clipboard. Full answer Be aware that copying/pasting from the system clipboard will not work if :echo has(‘clipboard’) returns 0. In this case, Vim is not compiled with the +clipboard feature and you’ll have to install a different version or recompile it. Some … Read more

Copy files to clipboard in C#

Consider using the Clipboard class. It features all the methods necessary for putting data on the Windows clipboard and to retrieve data from the Windows clipboard. StringCollection paths = new StringCollection(); paths.Add(“f:\\temp\\test.txt”); paths.Add(“f:\\temp\\test2.txt”); Clipboard.SetFileDropList(paths); The code above will put the files test.txt and test2.txt for copy on the Windows Clipboard. After executing the code you … Read more

Copy text to clipboard from bookmarklet

Since the new Clipboard API, this is easy in browsers that support it: javascript: navigator.clipboard.writeText(‘some text from somewhere’);null; Caveat: Any alerts or prompts in your bookmarklet will cause the document to lose focus, and the clipboard API will become unavailable. In that case you need to move focus back into the document before any subsequent … Read more

How to make Vim paste from (and copy to) the system’s clipboard?

TL;DR Try using “*yy or “+yy to copy a line to your system’s clipboard. Full answer Be aware that copying/pasting from the system clipboard will not work if :echo has(‘clipboard’) returns 0. In this case, Vim is not compiled with the +clipboard feature and you’ll have to install a different version or recompile it. Some … Read more

How can I copy a string to the clipboard within my console application WITHOUT adding a reference to System.Windows.Forms?

Platform invoking the clipboard APIs is a possible solution. Example: using System.Runtime.InteropServices; class Program { [DllImport(“user32.dll”)] internal static extern bool OpenClipboard(IntPtr hWndNewOwner); [DllImport(“user32.dll”)] internal static extern bool CloseClipboard(); [DllImport(“user32.dll”)] internal static extern bool SetClipboardData(uint uFormat, IntPtr data); [STAThread] static void Main(string[] args) { OpenClipboard(IntPtr.Zero); var yourString = “Hello World!”; var ptr = Marshal.StringToHGlobalUni(yourString); SetClipboardData(13, ptr); … Read more

How might I pass text data from the ruby console into my clipboard without saving to a file?

You can just echo it instead if there are no newline characters in the string; otherwise, use the IO class. Using echo: system “echo #{stringdata} | pbcopy” OR `echo #{stringdata} | pbcopy` Ruby will then just rip the text from memory, inject it into the shell command which opens a pipe between the echo and … Read more

Get CSV Data from Clipboard (pasted from Excel) that contains accented characters

Excel stores the string on the clipboard using the Unicode character encoding. The reason you get a square when you try to read the string in ANSI is that there is no representation for that character in your system’s ANSI codepage. You should just use Unicode. If you’re going to be dealing with localization issues, … Read more

tech