I'm wondering if there is a way to have MacVim become my default editor when I've SSH'ed into a server. Is there any way for the server's .vimrc file to launch a program on my Mac?
I ask because occasionally I'll be getting some help from our programmer on a project, and if he logs into my account from his computer and opens vim using my configuration the color scheme is usually pretty harsh since he isn't using a terminal that supports 256 colors. Would it be easier to have my .vimrc file set up so if it detects a gui (e.g., I'm using iTerm instead of Terminal.app) it loads the colorscheme I prefer?
Thanks for any advice!
Here's a way to use MacVim to edit files on your server, but it requires you to start MacVim on your local computer first.
First make sure you have netrw installed. Check :help netrw to confirm that it is.
Then after you start MacVim, you can type something like this:
:e scp://username#yourserverdomain.com/.bash_profile
And you should see the file open up in your MacVim vim session. Edit it and save.
Having ssh keys set up to automatically authenticate you into the server will help.
Related
Recently I've been creating my custom color scheme on VIM for RPGLE language and it works fine when I open files from my computer, but when I try to edit a file via FTP it doesn't work anymore.
Do I need some special config to achieve this?
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?
I'm looking to pair with people over tmux with Vim, but I've run into a snag. I've become so used to my Vim setup that I do not know how to navigate without some of my basic mappings that I've setup. That being said, if I SSH into somebody else's box, I don't really know my way around.
Is there a way to load some of my vimrc config when ssh-ing into someone else's box?
I suggest CoVim https://github.com/FredKSchott/CoVim
This is not depend on tmux.
If it's just your .vimrc file, you could :source that:
:source scp://myhost/.vimrc
Thanks to the netrw plugin, this transparently accesses the file from your system; of course, you could also explicitly mount your home directory and then use a normal filespec to the mounted files.
In theory, you could even add your remote ~/.vim directory to 'runtimepath', so that all of your customizations and plugins are loaded, but that probably leads to greatly increased startup times (due to the network accesses), potential conflict with the host's plugins, and is therefore not recommended.
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?
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.