Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solution for using Sublime Text to edit files on a local server I created with vagrant? [closed]

I have a headless Ubuntu server created with vagrant and normally use vagrant ssh to access and then mess around with the files.

I need to edit the files, and I'm not terribly keen on learning vim/emacs, so I'm wondering if I can use my editor of choice (Sublime Text 2) to edit the remote files.

How would you recommend I go about this? I've heard many solutions, FTP, rsync, vim/emacs, etc. but I'm not sure for my particular situation (Sublime and vagrant) what I would be best off doing.

like image 721
Doug Smith Avatar asked Jun 20 '13 13:06

Doug Smith


People also ask

How do I use remote server with Sublime Text?

Publishing files to the server with SublimeStart Sublime Text. On the File menu, click Open Folder. Select the folder on your local computer where you want to want edit files, and then click OK. In the sidebar, right-click the name of the folder you selected in step 3, click SFTP/FTP, and then click Map to Remote.

How to edit with Sublime Text?

Use the DevTools "Elements" panel. A new sub-pane is added to this panel. Select "Edit as HTML", then select an HTML node. When you are ready, press the button to open the content in the Sublime Text editor.

How do I use Sublime Text?

To run code in Sublime Text, go to Tools > Build System, and select the language for your code (Sublime comes with support for various languages like Python, Ruby, Bash, and more). Next, press Cmd+B on Mac or Ctrl+B on Windows to run your code.


2 Answers

By default Vagrant will set up a share with your host machine automatically... /vagrant on the server will be mapped to the folder containing your Vagrantfile this allows you to edit anything in this folder and the changes will be made instantly on the ubuntu server as well.

You can also set up other shared/synced folders... check out the documentation.

The other options you have are creating a samba share (or AFP on OSX) or something similar and then mounting the share in your host machine and using sublime as per usual.

like image 150
Matt Cooper Avatar answered Sep 20 '22 10:09

Matt Cooper


Sublime SFTP might be a good solution for you. After the free trial is does cost US$16, but it's definitely worth it if you routinely work with files across FTP/SFTP/FTPS. It is authored by the same guy who created Package Control. You should be able to configure vagrant to allow this.

Another option is to use sshfs with Vagrant to create a locally-mounted filesystem that you can access directly through ST2. If you're running on OSX, I highly recommend trying out Transmit. In my experience it's much easier to use than MacFUSE, is faster, a lot easier to set up, and is much more stable. Again, with the right config options vagrant should allow this pretty easily.

like image 45
MattDMo Avatar answered Sep 17 '22 10:09

MattDMo