. 安装Package Control插件 (如果安装好的朋友可以忽略这一步),安装是通过Sublime Text 2控制台。这是通过按Ctrl + `快捷访问。一旦打开,粘贴以下命令到控制台。
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')
然后回车。出现下图说明 Package Control 安装成功了,此时关闭编辑器。
2. 如果是在Windows和Linux平台上按Ctrl + Shift + P命令,如果是OS X按CMD + Shift + P命令,输入install 调出 Install Package 出现下图:
回车一下,等几秒钟出现下图:
然后键入sftp,如下图,然后按回车。
出现下图说明安装成功了。
这时候在file菜单下面会出现SFTP/FTP选项,选择 SETUP SERVER选项修改如下代码:
{ // The tab key will cycle through the settings when first created // Visit http://wbond.net/sublime_packages/sftp/settings for help // sftp, ftp or ftps "type": "sftp", "sync_down_on_open": true, "host": "wangshangyou.com", "user": "", "password": "password", //"port": "22", "remote_path": "/", //"file_permissions": "664", //"dir_permissions": "775", //"extra_list_connections": 0, "connect_timeout": 30, //"keepalive": 120, //"ftp_passive_mode": true, //"ssh_key_file": "~/.ssh/id_rsa", //"sftp_flags": ["-F", "/path/to/ssh_config"], //"preserve_modification_times": false, //"remote_time_offset_in_hours": 0, //"remote_encoding": "utf-8", //"remote_locale": "C", }
然后保存,这样就可以连接了。下面介绍将一个项目上传:
在工具栏中点击Project - Add Folder to Project...,选择项目的文件夹。这样左侧会出现project文件夹,右键project,选择FTPSync - Setup FTPSync in this folder,之后会出来一个配置文件sftp-config.json,对配置文件进行修改,代码如下:
{ // The tab key will cycle through the settings when first created // Visit http://wbond.net/sublime_packages/sftp/settings for help // sftp, ftp or ftps "type": "ftp", "save_before_upload": true, "upload_on_save": false, "sync_down_on_open": false, "sync_skip_deletes": false, "confirm_downloads": false, "confirm_sync": true, "confirm_overwrite_newer": false, "host": "wangshangyou.com", "user": "", "password": "", //"port": "22", "remote_path": "/", "ignore_regexes": [ "\\.sublime-(project|workspace)", "sftp-config(-alt\\d?)?\\.json", "sftp-settings\\.json", "/venv/", "\\.svn", "\\.hg", "\\.git", "\\.bzr", "_darcs", "CVS", "\\.DS_Store", "Thumbs\\.db", "desktop\\.ini" ], //"file_permissions": "664", //"dir_permissions": "775", //"extra_list_connections": 0, "connect_timeout": 30, //"keepalive": 120, //"ftp_passive_mode": true, //"ssh_key_file": "~/.ssh/id_rsa", //"sftp_flags": ["-F", "/path/to/ssh_config"], //"preserve_modification_times": false, //"remote_time_offset_in_hours": 0, //"remote_encoding": "utf-8", //"remote_locale": "C", } 在project目录结构中选择文件右键上传,或者在命令输入框中输入命令。 这样就完成了。