1

I'd like to ssh to a remote server and vim a file.

I tried

ssh -t user@host "vim x"

which gave me errors:

Error detected while processing /home/michael/.vimrc:
line   58:
E538: No mouse support: mouse=a
line   91:
E474: Invalid argument: listchars=tab:▒~V▒\ ,eol:¬,trail:▒~K~E,extends:▒~]▒,precedes:▒~]▒
line  158:
E185: Cannot find color scheme solarized
line  289:
E484: Can't open file /home/michael/.vimrc_machine_specific
Press ENTER or type command to continue

and so of course the vim window was not properly configured when I entered it.

These errors are from the server's .vimrc, /home/michael/.vimrc . The last one is especially surprising, as it is generated by a try/catch that shouldn't cause an error:

try
  source ~/.vimrc_machine_specific
catch
  " No such file? No problem; just ignore it.
endtry

If I ssh to log in to the server and then type 'vim x', all works correctly -- the colorscheme loads, the missing .vimrc_machine_specific is quietly ignored, the mouse works, etc.

Local machine:

  • Cygwin on Win7
  • ssh version: OpenSSH_5.1p1, OpenSSL 0.9.8o 01 Jun 2010

Remote machine:

  • uname -a: Linux <hostname> 2.6.32-220.2.1.el6.x86_64 #1 SMP Fri Dec 23 02:21:33 CST 2011 x86_64 x86_64 x86_64 GNU/Linux
  • ssh version: OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
  • vim version: 7.2 (2008 Aug 9), including patches 1-411, Huge version without GUI.

Any idea what I'm doing wrong?

  • It does not solve your problem, but you can try a software I wrote: sbc. It looks like bcvi but is more flexible. One of the features is to use your local vim to edit remote files (and you can call your local vim when connected via SSH on remote machine), so you won't need to execute remote's .vimrc file. – Álvaro Justen May 6 '12 at 19:46
2

I had the same problem with invalid listchars until I moved this line above it in my vimrc.

set encoding=utf-8

  • This worked for me. The reason it's happening only from within ssh is probably because your locale is different from what you expect. Quotinv vim help: "Normally 'encoding' will be equal to your current locale. This will be the default if Vim recognizes your environment settings." – PonyEars Jan 6 '17 at 3:00
0

The program vi is often a tiny version of Vim that is built without many of Vim's features so as to have a small disk and memory footprint. Executing :version will show you in the top four lines which version of Vim you are running. Try

ssh -t user@host vim x

instead.

  • Nope, I'm afraid that's not the problem; I have 'alias vi=vim'. Both show version 7.2. – Michael Gundlach Apr 24 '12 at 13:17
  • What matters is not the version number but the feature set, also called the version. It can be "tiny", "small", "normal", "big" or "huge" and is the first word on the fourth line of the ":version" output. – garyjohn Apr 24 '12 at 14:16
  • 2
    @MichaelGundlach: Also, your ssh command is not launching vi/vim from an interactive shell, so your aliases won't have any effect. – garyjohn Apr 24 '12 at 15:55
  • Thanks, garyjohn. It's 'huge'. I verified the same problem exists using 'vim' instead of 'vi', to simplify the question. – Michael Gundlach Apr 26 '12 at 14:12
0

For thrills, install a local X server in cygwin, then when calling ssh use -X to forward X11 traffic.

Perhaps this would resolve the issue with mouse support mentioned above? this is probably more of a workaround than anything else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.