#[1]Edit [2]Vim Tips Wiki (en) [3]copyright [4]Vim Tips Wiki Atom feed
FANDOM
[5]Games [6]Movies [7]TV [8]Video
Wikis
* [9]Explore Wikis
* [10]Community Central
* [11]Start a Wiki
Search
____________________ (BUTTON) (BUTTON)
* [12]Sign In
* Don't have an account?
[13]Register
[14]Start a Wiki
[15]Vim Tips Wiki
[16]Vim Tips Wiki
1,640 Pages
[17]Add new page
* [18]Community portal
* [19]To do
* Explore
+ [20]Wiki Activity
+ [21]Random page
+ [22]Community
+ [23]Videos
+ [24]Images
in:
[25]Duplicate, [26]Review, [27]VimTip,
and 2 more
* [28]File Handling
* [29]Integration
Editing remote files via scp in vim
[30]Edit
* [31]Edit source
* [32]History
* [33]Talk (0)
[34]Share
__________________________________________________________________
Duplicate tip
This tip is very similar to the following:
* [35]VimTip542
These tips need to be merged – see the [36]merge guidelines.
Please review this tip:
* This tip was imported from vim.org and needs [37]general review.
* You might [38]clean up comments or [39]merge similar tips.
* Add suitable [40]categories so people can find the tip.
* Please [41]avoid the discussion page (use the Comments section
below for notes).
* If the tip contains good advice for current Vim, remove the
{{review}} line.
[42]Tip 337 [43]Printable [44]Monobook [45]Previous [46]Next
created 2002 · complexity intermediate · author Matthew Weier O'Phinney
· version 6.0
__________________________________________________________________
Vim 6.x has the netrw plugin installed as a standard plugin. It allows
you to edit files via ftp, rcp, scp, or http. If your username differs
on the remote host, however, and you're trying to use scp, things can
get a little weird, particularly if you're not editing a document under
your user tree.
To get around this, try opening the file as follows:
vim scp://
[email protected]//absolute/path/to/document
Similarly, you can open the file from within Vim in a new buffer by
running:
:e scp://
[email protected]//absolute/path/to/document
or in a new tab using:
:tabe scp://
[email protected]//absolute/path/to/document
Notice two things:
1. remoteuser@: This is used to specify the user name on the remote
server. Without this, it will use the user's name on the local
computer. Often that will come from the $USERNAME environment
variable. If the user has the same name on the local computer and
the remote server, this part is unnecessary. If you're unsure
whether it's needed, use it just to be safe.
2. Double slashes ("//") between the hostname and file path: At least
one slash is needed to separate the remote server's hostname from
the file path. That slash is not included in the path used to
reference the file on the remote server. If the path to the file is
absolute, then it must begin with a slash, giving two slashes
between the hostname and file path as shown above.
However, if the file to be edited is contained within the home
directory of the remote user, a relative path may be used, which
should not use a second slash. For example, if the absolute path to
the file to be edited is
/users/remoteuser/relative/path/to/document and the home directory
for remoteuser is /users/remoteuser, then the following command
will open that file:
vim scp://
[email protected]/relative/path/to/document
Comments[47] [yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D] Edit
The [48]latest netrw.vim has several improvements. Later Windows ftp is
handled, new protocols (rsync, cadaver, fetch), user fixup functions,
etc.
__________________________________________________________________
How can we store the password? It prompts for password each time we
save!
__________________________________________________________________
I just got this working on Win2k w/ PuTTY's command line scp program
[49]
http://www.chiark.greenend.org.uk/~sgtatham/putty/
* copy pscp.exe into your path somewhere as scp.exe
* put "let g:netrw_cygwin= 0" in your $VIM/_vimrc
__________________________________________________________________
A possible gotcha:
If you don't put the path as specified (and noted) in the tip, you may
get a non-intuitive error: not putting "//" between the hostname and
the *absolute* path of the file you edit may cause vim to try to
retrieve the file via rcp, as in
:!rcp scp://
[email protected]:t1
and result in an error. Also be careful that you put the absolute path
of the file on the remote machine, not the path relative to the remote
user's home directory.
__________________________________________________________________
Using relative paths is quite normal and well supported. Try
:r scp://m@machine/t1
__________________________________________________________________
Someone was asking if you could define the port for ftp
vim ftp://[user@]machine[[:#]portnumber]/path
try that...just like any other url.
vim [50]
ftp://stankonia@domainname.com:6090/public_html/index.html
I guess that would work.
__________________________________________________________________
There is a nice way to save your passwords: Create .netrc under you
home directory and put lines in, one per ftp machine, like this one:
machine yourftp.somewhere.org login yourlogin password "yoursecret"
__________________________________________________________________
ftp remote edit is OK.
Run command:
gvim [51]<host>//<path_2_file> ftp://<host>//<path_2_file>;
Then enter user name and password.
__________________________________________________________________
If everything seems to be setup correctly but you're still unable to
access a file with ftp. Check the permissions on your .netrc file. If
.netrc is readable by anyone else besides the owner then ftp auto
fails.
chmod 600 .netrc
__________________________________________________________________
Solved for me on windows with putty, in vimrc:
let g:netrw_cygwin = 0
let g:netrw_scp_cmd = "\"C:\\Program Files\\PuTTY\\pscp.exe\" -pw mypasswd "
and now run from wincommander:
gvim scp://
[email protected]/file.txt
__________________________________________________________________
Get the latest version to fix any problems you are having.
__________________________________________________________________
Was getting a bit annoyed with having to type the full path a remote
user's file when I'm using scp and connecting as root on the remote end
to edit a local user's file on the remote site and found out that I
could do this and vim did "The Right Thing"
vim scp://
[email protected]/~user/public_html/.htaccess
That was a lot nicer than having to bother with:
vim scp://
[email protected]//home/user/public_html/.htaccess
Maybe not such a pain in that example, but if you're working with an
Ensim for Linux system, you've got everything chrooted which makes you
have to type a ridiculously long path such as:
vim scp://
[email protected]//home/virtual/site2/fst/var/www/html/.htaccess (yawn)
__________________________________________________________________
To change the scp port, there's several options. A quick one would be
while you've opened vim to type this:
:let g:netrw_scp_cmd="scp -q -P <desired_new_port>"
and then just type:
:e scp://my_user@remote_hostname//path/to/remote/file
--> I think a better solution is to use ssh-mechanisms, i.e. the
~/.ssh/config file:
Host lala
HostName test.machine.example.net
User remoteuser
IdentityFile ~/.ssh/id_for_test.machine
Port 57
__________________________________________________________________
I have discovered how to make passive mode ftp work. See
[52]
http://alecthegeek.github.io/blog/2007/02/06/handy-hack-how-to-use-
vim-netrw-in-ftp-passive-mode/
__________________________________________________________________
Try "C:\Program Files\Vim\vim71\gvim.exe" --remote-tab !.! in WinSCP to
open each file in a separate tab in the same gVim instance. I also
clicked the "External Editor Opens Multiple Files in one window"
checkbox. There is another option --remote-silent that will suppress
the first warning that there is no gVim already running, but you cannot
use it with the --remote-tab option. I prefer to ack. the one warning
rather than making sure I'm in a new tab before opening anything.----
--Preceding [53]unsigned comment added by 161.88.255.139 (talk •
[54]contribs) 20:49, 18 April 2008
__________________________________________________________________
Use "C:\Program Files\Vim\vim71\gvim.exe" --remote-tab-silent !..! in
WinSCP as External Editor works just fine.
__________________________________________________________________
For windows I would suggest adding PuTTY to the system path (or not)
and simply set the g:netrw_cygwin=0, and g:netrw_scp_cmd=<PATH TO PSCP>
and use Pageant to manage your private keys; that way you don't have to
keep your password in your vimrc file. Pageant provides the key to PSCP
when it tries to connect.
--Preceding [55]unsigned comment added by 216.145.54.7 (talk •
[56]contribs) 11:56 UTC, 20 May 2009
__________________________________________________________________
[57]bcvi is a utility that works with SSH/SCP and the Vim NetRW plugin
described above. When you log into a remote server with SSH+bcvi, you
can cd into any directory then type vi filename and the gvim command
will get launched back on your workstation, with the correct SCP URL to
point to the file on the server. If that sounds confusing, the [58]bcvi
article clarifies things with examples and pictures.
__________________________________________________________________
Retrieved from
"[59]
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim?ol
did=40481"
[60]Categories:
* [61]Duplicate
+
+
* [62]Review
+
+
* [63]VimTip
+
+
* [64]File Handling
+
+
* [65]Integration
+
+
* (BUTTON) Add category ____________________
(BUTTON) Cancel (BUTTON) Save
Community content is available under [66]CC-BY-SA unless otherwise
noted.
Fan Feed
Explore Wikis
* [67][56?cb=20190910004306]
Xavier Riddle and the Secret Museum Wiki
* [68][56?cb=20191109223830]
Flipline Studios Fanon Wiki
* [69][56?cb=20190821004108]
SMG4 Wiki
Explore properties
* [70]Fandom
* [71]Gamepedia
* [72]D&D Beyond
* [73]Muthead
* [74]Futhead
Follow Us
*
*
*
*
*
Overview
* [75]About
* [76]Careers
* [77]Press
* [78]Contact
* [79]Terms of Use
* [80]Privacy Policy
* [81]Global Sitemap
* [82]Local Sitemap
Community
* [83]Community Central
* [84]Support
* [85]Help
* [86]Do Not Sell My Info
Advertise
* [87]Media Kit
* [88]Contact
Fandom Apps
Take your favorite fandoms with you and never miss a beat.
*
*
D&D Beyond
*
*
Vim Tips Wiki is a FANDOM Lifestyle Community.
[89]View Mobile Site
[90][wikiabarIcon.png] JokeyPsych [91][wikiabarIcon.png] EndgameHonest
[92][wikiabarIcon.png] GalaxyQuest
References
Visible links
1.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim?action=edit
2.
https://vim.fandom.com/opensearch_desc.php
3.
https://www.fandom.com/licensing
4.
https://vim.fandom.com/wiki/Special:RecentChanges?feed=atom
5.
https://www.fandom.com/topics/games
6.
https://www.fandom.com/topics/movies
7.
https://www.fandom.com/topics/tv
8.
https://www.fandom.com/video
9.
https://www.fandom.com/explore
10.
https://community.fandom.com/wiki/Community_Central
11.
https://community.fandom.com/wiki/Special:CreateNewWiki
12.
https://www.fandom.com/signin?redirect=
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim
13.
https://www.fandom.com/register?redirect=
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim
14.
https://community.fandom.com/wiki/Special:CreateNewWiki
15.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim
16.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim
17.
https://vim.fandom.com/wiki/Special:CreatePage
18.
https://vim.fandom.com/wiki/Vim_Tips_Wiki:Community_Portal
19.
https://vim.fandom.com/wiki/Vim_Tips_Wiki:Todo
20.
https://vim.fandom.com/wiki/Special:WikiActivity
21.
https://vim.fandom.com/wiki/Special:Random
22.
https://vim.fandom.com/wiki/Special:Community
23.
https://vim.fandom.com/wiki/Special:Videos
24.
https://vim.fandom.com/wiki/Special:Images
25.
https://vim.fandom.com/wiki/Category:Duplicate
26.
https://vim.fandom.com/wiki/Category:Review
27.
https://vim.fandom.com/wiki/Category:VimTip
28.
https://vim.fandom.com/wiki/Category:File_Handling
29.
https://vim.fandom.com/wiki/Category:Integration
30.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim?veaction=edit
31.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim?action=edit
32.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim?action=history
33.
https://vim.fandom.com/wiki/Talk:Editing_remote_files_via_scp_in_vim?action=edit&redlink=1
34.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim
35.
https://vim.fandom.com/wiki/VimTip542
36.
https://vim.fandom.com/wiki/Vim_Tips_Wiki:Merge_guidelines
37.
https://vim.fandom.com/wiki/Vim_Tips_Wiki:General_guidelines
38.
https://vim.fandom.com/wiki/Vim_Tips_Wiki:Comment_guidelines
39.
https://vim.fandom.com/wiki/Vim_Tips_Wiki:Merge_guidelines
40.
https://vim.fandom.com/wiki/Vim_Tips_Wiki:Category_guidelines
41.
https://vim.fandom.com/wiki/Vim_Tips_Wiki:Discussion_guidelines
42.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim
43.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim?printable=yes
44.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim?useskin=monobook
45.
https://vim.fandom.com/wiki/VimTip336
46.
https://vim.fandom.com/wiki/VimTip338
47.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim?action=edit§ion=1
48.
http://www.drchip.org/astronaut/vim/index.html#NETRW
49.
http://www.chiark.greenend.org.uk/~sgtatham/putty/
50.
ftp://stankonia@domainname.com:6090/public_html/index.html
51. ftp:///
52.
http://alecthegeek.github.io/blog/2007/02/06/handy-hack-how-to-use-vim-netrw-in-ftp-passive-mode/
53.
http://en.wikipedia.org/wiki/Signatures
54.
https://vim.fandom.com/wiki/Special:Contributions/161.88.255.139
55.
http://en.wikipedia.org/wiki/Signatures
56.
https://vim.fandom.com/wiki/Special:Contributions/216.145.54.7
57.
http://sshmenu.sourceforge.net/articles/bcvi/
58.
http://sshmenu.sourceforge.net/articles/bcvi/
59.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim?oldid=40481
60.
https://vim.fandom.com/wiki/Special:Categories
61.
https://vim.fandom.com/wiki/Category:Duplicate
62.
https://vim.fandom.com/wiki/Category:Review
63.
https://vim.fandom.com/wiki/Category:VimTip
64.
https://vim.fandom.com/wiki/Category:File_Handling
65.
https://vim.fandom.com/wiki/Category:Integration
66.
https://www.fandom.com/licensing
67.
http://bit.ly/en-spotlight-xavierriddle
68.
http://bit.ly/en-spotlight-fliplinestudiosfanon
69.
http://bit.ly/en-spotlight-smg4
70.
https://www.fandom.com/
71.
https://www.gamepedia.com/
72.
https://www.dndbeyond.com/
73.
https://www.muthead.com/
74.
https://www.futhead.com/
75.
https://www.fandom.com/about
76.
https://www.fandom.com/careers
77.
https://www.fandom.com/press
78.
https://www.fandom.com/about#contact
79.
https://www.fandom.com/terms-of-use
80.
https://www.fandom.com/privacy-policy
81.
https://community.fandom.com/Sitemap
82.
https://vim.fandom.com/wiki/Local_Sitemap
83.
https://community.fandom.com/wiki/Community_Central
84.
https://fandom.zendesk.com/
85.
https://community.fandom.com/wiki/Help:Contents
86.
https://www.fandom.com/do-not-sell-my-info
87.
https://www.fandom.com/mediakit
88.
https://www.fandom.com/mediakit#contact
89.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim
90.
http://bit.ly/31KuElR
91.
https://bit.ly/EndgameHT
92.
https://fandom.link/NeverSurrender
Hidden links:
94.
https://www.fandom.com/
95.
https://www.fandom.com/
96.
https://www.facebook.com/getfandom
97.
https://twitter.com/getfandom
98.
https://www.youtube.com/fandomentertainment
99.
https://www.instagram.com/getfandom/
100.
https://www.linkedin.com/company/157252
101.
https://itunes.apple.com/us/app/fandom-videos-news-reviews/id1230063803?ls=1&mt=8
102.
https://play.google.com/store/apps/details?id=com.fandom.app&referrer=utm_source%3Dwikia%26utm_medium%3Dglobalfooter
103.
https://apps.apple.com/us/app/d-d-beyond/id1263629972
104.
https://play.google.com/store/apps/details?id=com.curse.dndbeyond&hl=en&referrer=utm_source%3Dwikia%26utm_medium%3Dglobalfooter
105.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim
106.
https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim