Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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

3 Answers 3

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.

share|improve this answer
    
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

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.

share|improve this answer

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

set encoding=utf-8

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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