How do I paste from PuTTY into Vim 8.0? - windows

Scenario
From a Windows 10 Anniversary Update client ...
Open a web browser, copy / paste some text from a website (eg. GitHub)
Use PuTTY 0.67 to SSH to a Linux VM (eg. Ubuntu 16 Xenial Xerus)
Open a file in Vim
Hit i to change into Insert mode
Right-click to paste the clipboard contents
Issue
Unfortunately, when I right-click in the PuTTY session, rather than pasting clipboard contents, what's actually happening is that Vim is going from INSERT mode to (insert) VISUAL mode. I don't think I've ever seen anything like this before.
Question
Does anyone know why this is happening, and how I can paste my Windows client clipboard into the SSH / Vim session?

It appears that this issue is due to a change in defaults for VIM version 8.0 and higher.
Previous versions had mouse mode turned off (mouse=), but the new default is mouse mode turned on (mouse=a).
There are 3 ways to deal with this situation:
Adapt to it: With mouse mode turned on, the new way to paste is shift-right-click (at least in PuTTY)
Change it: You can turn off mouse mode for your current VIM session by typing :set mouse= and <enter>
Revert it: You can override the new defaults by calling VIM with the "C" switch (vim -C {filename}) and it will revert back to the Vi "compatible" settings for that session
Of course you can always add set mouse= to your .vimrc file to make it permanent. But that doesn't work for me because I hop around on too many different systems.

I solved this problem by turning off mouse mode.
:set mouse=

I faced the same problem
You just need to change in the vmrc file
vim $HOME/.vimrc
set the following in the file
set mouse-=a to .vimrc
It worked fine

Related

Copy Paste in Bash on Ubuntu on Windows

How to execute a copy paste operation from Windows 10 to the Bash on Ubuntu on Windows environment?
I tried the following:
ctrl + shift + v
right click to paste
Any suggestions?
Update 2019/04/16: It seems copy/paste is now officially supported in Windows build >= 17643. Take a look at Rich Turner's answer. This can be enabled through the same settings menu described below by clicking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste".
Another solution would be to enable "QuickEdit Mode" and then you can paste by right-clicking in the terminal.
To enable QuickEdit Mode, right-click on the toolbar (or simply click on the icon in the upper left corner), select Properties, and in the Options tab, click the checkbox next to QuickEdit Mode.
With this mode enabled, you can also copy text in the terminal by clicking and dragging. Once a selection is made, you can press Enter or right-click to copy.
To get right-click to paste to work:
Right-click on the title bar > Properties
Options tab > Edit options > enable QuickEdit Mode
At long last, we're excited to announce that we FINALLY implemented copy and paste support for Linux/WSL instances in Windows Console via CTRL + SHIFT + [C|V]!
You can enable/disable this feature in case you find a keyboard collision with a command-line app, but this should start working when you install and run any Win10 builds >= 17643. Select "Properties" from the menu to access the following dialog box.
Thanks for your patience while we re-engineered Console's internals to allow this feature to work :)
You can use AutoHotkey (third party application), the command below is good with plain alphanumeric text, however some other characters like =^"%#! are mistyped in console like bash or cmd. (In any non-console window this command works fine with all characters.)
^+v::SendRaw %clipboard%
Right-click the title bar, select context menu Edit -> Paste (until they fix the control key shortcuts)
As others have said, there is now an option for Ctrl+Shf+Vfor paste in Windows 10 Insider build #17643.
Unfortunately this isn't in my muscle memory and as a user of TTY terminals I'd like to use Shf+Ins as I do on all the Linux boxes I connect to.
This is possible on Windows 10 if you install ConEmu which wraps the terminal in a new GUI and allows Shf+Ins for paste. It also allows you to tweak the behaviour in the Properties.
The Console looks like this:
Copy options:
Paste options:
Shf+Ins works out of the box. I can't remember if you need to configure bash as one of the shells it uses but if you do, here is the task properties to add it:
Also allows tabbed Consoles (including different types, cmd.exe, powershell etc). I've been using this since early Windows 7 and in those days it made the command line on Windows usable!
Like it has been written before:
Right Click on Bash on Ubuntu on Windows Icon if you have it on a Task Bar Shortcut Icon
Click on Properties
Select Options Tab on the Properties Window
Check the QuickEditMode option
Click Apply
Now you are able to open a new Bash Terminal and just use Right-Click to paste
In order to be able to copy from Terminal, Just use CTRL+M and this will enable you to select and copy selected Text.
For pasting into Vim in the terminal (bash on ubuntu on windows):
export DISPLAY=localhost:0.0
Not sure how to copy from Vim though :-(
Alternate solution over here, my windows home version Windows Subsystem Linux terminal doesn't have the property to use Shift+Ctrl (C|V)
Use an actual linux terminal]1
Install an X-server in Windows (like X-Ming)
sudo apt install <your_favorite_terminal>
export DISPLAY=:0
fire your terminal app, I tested with xfce4-terminal and gnome-terminal
windows #ubuntu #development
For just copying (possibly long) texts to the Windows clipboard, I have found that just piping the output to clip.exe (including the .exe file extension) works fine for me. So:
$ echo "Hello World" | clip.exe
lets me paste Hello World using Ctrl-V anywhere else.
Now that I have posted this, I notice that related question Pipe from clipboard in linux subsytem for windows includes this and a command solution for pasting from the Windows clipboard as well.
you might have bash but it is still a windows window manager. Highlite some text in the bash terminal window. Right click on the title bar, select "Edit", select "Copy", Now Right Click again on the Title bar, select "Edit" , Select "Paste", Done. You should be able to Highlite text, hit "Enter" then Control V but this seems to be broken
For autohotkey users, a full answer is:
#IfWinActive ahk_class ConsoleWindowClass
^+v::SendInput %clipboard%
Which checks that you're in a console (windows or ubuntu) before pasting from the windows clipboard.
That turned out to be pretty simple. I've got it occasionally. To paste a text you simply need to right mouse button click anywhere in terminal window.

Opening files into an existing vim session (Cygwin/mintty)

I am looking for ideas to open files into an existing vim session.
I am working on Windows + Cygwin + Mintty. I usually have 3 to 4 opened terminals (2-3 vim sessions + 1 shell, build environment). I don't use tmux/screen because it's easier to use the native Windows's window manager to switch in between my terminal windows. Because I have 2 wide-screen monitors I can use the 2 half of both screens for my terminals which gives me an awesome working environment. With the help of an AHK script, I can use shortcuts to switch/rotate or even to reposition my terminals in the desired position.
I rather prefer vim over gvim for many reasons. I can achieve almost all the gvim features (scroll, mouse selection, copy, paste, etc. I am one of those who think that using the respectable y/P commands is a bit crippling when you need to use plenty of other softwares that use /. I always get confused to use different shortcuts for each software I am using.
Now the core issue. I would like to open a file from the Windows explorer into an existing vim session. I found a horrible solution using a Perl script with the Win32::API in order to look for an existing mintty terminal with Vim in the title. Then I activate the window and send <esc>:e path/file<cr> to it.
It works pretty well but I am looking for a better solution like gvim --remote that works with my console vim. Unfortunately I don't have such options with my vim even though if I built it with the -with-x configure option.
So, I am looking for some suggestions to achieve a more honorable solution (socket/adding the feature directly to vim/using a smarter ahk script/etc.)
gvim --remote should work with console vim if you start vim with vim --servername GVIM. Alternatively, choose another servername and use vim --servername foo --remote.

Terminal window inside Sublime Text 2

I saw this project that basically opens a new terminal window from sublime text-2.
What I'm looking for is a way to open the terminal inside sublime text 2 via console.
Does anyone knows how can I do that?
SublimeREPL does what you want
https://github.com/wuub/SublimeREPL/
Of course, there are some limitations because the window of Sublime Text 2 is not originally designed for continuous running buffer of stdin input.
+ 2 years (sorry) - but my solution in ubuntu was to open both sublime and my (real) terminal in the same window, shrink and stretch the terminal to cover the lower portion of the screen, then right click on the terminal and select "keep on top" - works a treat.
EDIT 04/23/2019: Terminus extends TerminalView & adds:
Windows support
Continuous history
Easily customizable themes (see Terminus Utilities)
Unicode support
256 colors support
Better xterm support
Terminal panel view
imgcat support (also works on Linux / WSL)
Bind key shortcut to open shell on file path (e.g. ctrl+alt+t to open):
{
"keys": ["ctrl+alt+t"], "command": "terminus_open", "args": {
"cwd": "${file_path:${folder}}"
}
}
Original Answer:
I've tried pretty much every terminal package around, what you want is TerminalView:
To bind a key shortcut, simply add it to your user key bindings file:
{ "keys": ["ctrl+alt+t"], "command": "terminal_view_open" },
Use Glue. It is a plugin that provides an interface to your shell from the Sublime Text. So basically it a terminal for Sublime Text.
https://packagecontrol.io/packages/Glue
Like #mikko I also decided that due to the limitations of the shell add-ons for sublime to stick with a real terminal window - I've got too used to the F2-F4 workflow of geany.
So really the issue for me is quickly flip-flopping between the two windows easily. To that end, I knocked this up - to be fired from F12 (or whatever you want) in your desktop manager (XFCE in my case)
Note, I launch sublime a from shortcut with terminator -T st3_bash & st3 so I've got a known bash window title for switching focus to.
https://gist.github.com/robertpearce/8725224
I know this code is really, (really) bad, and it'll fail if you have multiple sublime's open, but i don't ever have that anyhow.
Feel free to fork and improve it.
I have always wanted a way to open terminal inside sublime text. After trying out different options I have come to a solution of installing guake terminal as a work around on linux systems, follow the steps below.
Run the command sudo apt-get install guake
Press F12 (for opening terminal)
Now you can use the terminal without leaving sublime.
For windows :
Install Conemu
Have the Quake settings as shown in the pic below
Press ctrl + ~ (for opening terminal)
Note: This is just a workaround. Guake is basically a terminal package for ubuntu-like linux systems.

byobu Hard Status line scrolls the screen when updating

Wanting to give byobu a looksee as a screen 'update' of sorts. I start it with
byobu
and instead of the status line sitting at the bottom of the screen, everytime it updates it pushes to an additional line underneath the previous one. before long, the screen (putty) is filled with status line echoes.
How do I stop this?
running puttytray v0.62 on win7 to ubuntu 12.04
Putty defaults to a translation encoding of ISO-8859-1 where as Ubuntu sends out UTF-8 encoding.
Click on your server in the Load, save or delete a stored session window. Then click on the Load button.
Next, in the Category panel on the left click on:
Window -> Translation
Change the drop down under "Received data assumed to be in which character set" to UTF-8.
Once you do that then click on Session in the top of the Category panel and then click on save in the stored sessions area.
I am not saying this is the correct fix. I am just telling you all what fixed it for me without having to do any crazy stuff to the server.
Cheers!
This seems to be an issue with the default byobu backend. By default, byobu in Ubuntu 12.04 uses tmux as the backend. You can change this by running byobu-select-backend and selecting screen (option 2).
While not a solution as to why tmux is doing this on PuTTY sessions, it fixes your issue for the screen scrolling.
The UTF-8 setting works wonders. I usually set this together with Terminal => Keyboard => "Function keys and kepad" from "ESC[n~" to "Xterm R6" and save it as default configuration in Putty. That last option enables the use of the F key functions in Byobu. It's pretty much useless without.
I had a similar issue on a debian Testing/SID server, and it was an issue with several detached screen sessions loose on the system. ps aufx |grep -i screen should find orphaned screen sessions.
I tried sudo byobu-select-backend and tmux is the default on Debian Testing as well, I chose 'screen' but when I tried $ byobu the same scrolling behaviour ensued.
So I ran $ byobu-select-backend as my regular user and selected 'screen' again.
This time, running byobu showed me the detached screen sessions, so I could select them and shut them down gently.
#phanku's answer, namely that the terminal's encoding should be set to UTF-8, allowed me to fix the same problem that the OP described when accessing a byobu session (on Ubuntu 12.04) from a Mac OS X iterm with the help of Michael Hendrick's post that describes setting iTerm to UTF-8:
menu: View -> Show Session Info
Session tab: change Encoding from "Western (ASCII)" to "Unicode (UTF-8)".
for me the problem was related to how compatibility was set:
in the terminal, go to:
right-click, choose 'profiles' > 'profile preference'
choose the 'compatibility' tab
change 'ambiguous-width characters' to 'Narrow'
or
just click on the 'reset' button
it worked for me ...
I use iTerm2 in macOS and run into the same problem. The encoding is already set to UTF-8 but no help. Here's the solution that works for me:
Open Preferences > Profiles
Choose the profile with the problem
Go to Text tab on the right
Uncheck the Treat ambiguous-width characters as double width option
Done.

Why is my Ctrl-key disabled in iTerm.app?

I'm trying to use the new iTerm app on my Snow Leopard Mac, but my Ctrl seems to be completely dead (as in non-responsive, as in nothing happens when I type Ctrl+a except for an outputed 'a') and I haven't found anything useful while googling. The closest match was this thread here on stackoverflow, but everything in Terminal.app works as it should.
And, even more strange - I can Ctrl+z myself out of applications, but I can't save files in Emacs (C-x C-s) or any other keyboard shortcuts that uses a Ctrl shortcut. And it's not local, since Ctrl is as broken on my iMac as it is on other unix computers I've sshed onto with iTerm. I've tried both in bash and zsh.
I've tried to remove all files concerning iTerm.app in my ~/Library/Application Support, and I've tried the very latest version (currently 13 h old) of iTerm I could lay my hands on, but to no avail.
Any ideas?
This seems to be an iTerm bug.
You can work around it by creating a key mapping in the profile settings.
Add a mapping for ^x so it sends 0x18 (which is the encoded form of ctrl+x).
I suggest to check this post to see if the ctrl key is enabled in your preferences
https://apple.stackexchange.com/questions/52041/how-to-press-control-key-on-mac
Did you try to configure key bindings for this terminal emulator as specified in the iTerm wiki:
http://code.google.com/p/iterm2/wiki/Keybindings
at last, have you try set -o emacs or set -o vi?
If it works, set it in your ~/.bashrc to run it at login.

Resources