VIM support to upload via SFTP - vim

I am used to Sublime's plugin that let's you do a mapping between your local project and a remote project. By doing so, when you are done editing a file, you can do a right click and "Upload file" action which automatically updates the file in the remote server.
I am wondering what would be the best way to do this while programming with VIM. I am looking for an easy way to be able to map a local project to a remote one and be able to upload the file easily.
Thanks

If all you want is to edit files on a remote server,
try vim's netrw feature:
vim scp://you#yourserver//path/to/directory/
Edit a file directly:
vim scp://you#yourserver//path/to/directory/somefile.txt
Or if you are already in vim, hit ESC, then type:
:e scp://you#yourserver//path/to/directory/
This assumes that:
you have ssh installed (usually the case for Linux or OSX; if you are on Windows then it depends).
you have ssh access to the server via some convenient method (sshagent and keys)

Most serious FTP clients let you edit remote files locally. Filezilla, gFTP, Transmit, Cyberduck, YummyFTP… they all have their own "Edit in…" button. GUI FTP clients may not be sexy hacker tools but they work very well.
Some of those serious FTP clients have synchronisation features or folder watchers. It might be worth your time to look around for such a feature.
Of course, you can also use Vim itself to edit a remote file via FTP or SFTP:
$ vim sftp://user#machine/filename
$ vim ftp://user#machne/filename
and list remote files:
$ vim sftp://user#machine/directory/
See :help netrw for more info.
Did you consider using a VCS like Subversion, Git or Mercurial?

Related

kdevelop detect concurrent file opens

My favorite editor, geany, has an option "Disk check timeout", after this timeout it checks if someone else has overwritten the file that I'm editing. This is a simple tool to detect if two people work on the same file (we don't use a version control system). Is there an option or a plugin for kdevelop that does the same thing?
Edit: as Zhigalin said KDevelop does the check automatically but only for local files, I need it for files opened using sftp.
In KDevelop this check is always active, you will get a popup as soon as you focus on that file in the editor.
Edit: if you are speaking of remote files than the reply is no, there is no such functionality.
So you have 4 options:
File a proposal here (which probably won't get implemented soon because of few active developers)
Patches are always welcome
[suggested] Start using a version control system like Git, there are even tools to automatically deploy on server when you make commit on a specific branch.
Use AutoFS(FUSE) to mount your server as a local folder.

Workflow: Working with git and sandbox on linux

I'am a linux users and web developer.
Actually I'm using KDE as desktop environment and Kate as IDE.
I'm working for a company and we're using remote sandbox for development.
This is my actual workflow:
Connect to remote sandbox via sftp using Dolphin (file Manager)
Open the file that I want edit and save it
Show the changes in the browser
When I've finish I must copy the file that I've edited from remote to my git local folder and commit changes.
In the past I've used SublimeText with "upload on save" plugin, but I can't actually with Kate.
Is there a better workflow with Linux and Kate (or similar) editors?
Thanks you
In my experience with this setup, the fastest way to work will be to have Konsole (or preferred shell application) open with an SSH connection to the sandbox. Git must be installed on the sandbox for this to work.
Alternatively, you can mount to the filesystem and manage the repository directly from your operating system, but I've found this to be unacceptably slow relative to the size of the repository. Moreover, there's something magical about the way Dolphin mounts to remote filesystems using virtual folders that I could never figure out how to navigate to in a shell. I ended up going back to gvfs so that I had a clear path.
Lastly, Kate is not an IDE - it's just an editor. Not knocking it, it's actually my editor of choice in which I spend half of my life looking at, so you've got a friend in me :) Nevertheless, I'm not aware of a git plug-in for it, but depending on personal preference, I'd bet you're never going to beat the git core console app.

Copy and paste content from one file to another file in VIM from remote machine

I have found lots of questions about coping content of a file in Vim from one file to another and of course there are various ways to do it (1-2). I'm working on a remote machine and I'm going to copy large amount of data from a file in Vim to my laptop. None of the methods I have found yet works for coping from a remote machine. I have to use scp for any thing that I need from the remote machine. Do you have any idea?
I can't use "*100yy to copy content and remote machine does not have
any graphical editor. – Abolfazl
Naturally, if the editor has no notion of a GUI or a window system, it cannot use the clipboard, let alone that of your networked laptop. One option is to use the copy function of the local terminal program where you enter ssh, but of course that is practically limited by the terminal size.
If your laptop runs Windows, I recommend using WinSCP instead of ssh and the remote vim - you can configure WinSCP to edit the remote file with your local gvim, with all its features.
In your terminal:
$ man ssh
/-X

How can I use local vim setting on AWS server?

Is there a faster way to edit AWS EC2 config file using my local env vimrc?
I found that it is very hard to edit file in remote server using default vim settings
Any one has good solution to make ourself better?
Remote editing
I suppose you're using ssh to log into your AWS server and launch Vim there. An alternative is to launch Vim on your local system, and open the remote file in there, e.g. via the built-in netrw plugin:
$ vim scp://hostname/path/to/file
or within Vim:
:edit scp://hostname/path/to/file
Sharing Vim configuration across machines
There are many different approaches for sharing your .vimrc and plugins across multiple machines. Possible solutions were recently collected at What is the best way to deal with vim plugins on multiple machines?

Vim FTP Plugin for IDE-like behavior

I have gVim (with: NERDTree, minibufexpl). Right now, I can edit files locally with IDE-like feel with NERDTree for a file explorer and minibuf for tabs.
However, I am used to editing files on dummy server I have set up at home. I use Zend Studio to edit files through FTP. Is this feature available in Vim? If so, does it "integrate" well with NERDTree? I would like to browse my FTP directory using NERDTree.
Thank you,
Wenbert
You can edit files remotely over ftp or sftp or scp or whatnot with vim:
vim ftp://user#host/some/file
Of course, this also works with tabs. Don't know about minibuf, though.
Unfortunately, the NERDTree plugin does not seem to support this. However, the :Explore command plays along just nicely.
Of course, you could simply use FTPFS to mount a remote directory and work with that as if it was local storage.

Resources