I access a sever over ssh on which I run vim for editing files. When I try to yank text from vim into an editor locally on my mac (lion) either with y OR "+y it does not work. I end up with the text I copied last locally. It does work if I just use p within vim alright.
相关问题
- Xcode debugger displays incorrect values for varia
- JavaScript File Transfer SSH
- Is there a way to report errors in Apple documenta
- Advice for supporting both Mac and Windows Desktop
- Emacs shell: save commit message
相关文章
- 如何让 vim 支持 .cshtml 文件的代码高亮
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- Check if directory exists on remote machine with s
- Auto-save in VIM as you type
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
Here's an update on the solution #2 from romainl. It creates and alias of the ssh command and launches the remotecopyserver if it's not running and installs the remotecopy(rclip) in the remote server. In short, you don't have to do anything except paste the code snippet below into your bash_profile.
Once the alias is activated, you can normally use ssh and whenever you need to copy to local clipboard from vim, use
to copy the whole file to clipboard
to copy selected lines from visual mode. You have to press "Cmd+V" or "Ctrl+V" whenever it asks for the secret key.
Bonus
For those who work on Vagrant, there's a wrapper vssh which will execute vagrant ssh but also launches and install the necessary components.
Reference
Latest code snippet here - https://gist.github.com/ningsuhen/7933b206b92fc57364b2
http://endot.org/2011/12/04/remotecopy-copy-from-remote-terminals-into-your-local-clipboard/
https://github.com/justone/remotecopy
Caveats
The alias wraps the ssh command and there might be some unexpected issues.
ssho
is available if you need to execute ssh without the whole remotecopyserver thing. Alternatively, you can use the alias ssh2 and keep the ssh command as it is.My go-to solution is to edit the file with vim from your local machine via scp.
This keeps your buffer local and makes it easy to copy to your local clipboard.
The other advantage is that you get to use your local vim setup (.vimrc settings, plugins, etc.)
My first answer on stackoverflow, but I feel it's a cool (albeit tiny) trick and it's worth posting. So here's what I do :
When the text is printed onto the terminal, I select all the text with my mouse (the mouse scroll works since we're on the terminal window). Then copy that text with
Cmd
+C
and paste into my local text editor.The only flaw with this trick is that it's impractical to use if your files are tens of thousands of lines long since selecting all the lines with your mouse would be a task in itself. But for a file of ~2k lines it works well.