sublime編輯遠端伺服器檔案
sublime有個叫sftp的外掛,可以通過它直接開啟遠端機器上的檔案進行編輯,並在儲存後直接同步到遠端linux伺服器上。
用Package Control安裝外掛
按下Ctrl+Shift+P調出命令面板
輸入install 調出 Install Package 選項並回車,然後輸入FTP,下拉列表中會出現一些相關的外掛,
選中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, "sync_same_age": true, "host": "example.com", //遠端伺服器的地址IP 123.234.345.456 "user": "username", //root //"password": "password", //密碼可以不儲存,在輸入完地址和使用者的時候回車輸入 //"port": "22", "remote_path": "/example/path/", //要進入的目錄 比如 /data/www/ //"file_permissions": "664", //"dir_permissions": "775", //"extra_list_connections": 0, "connect_timeout": 30, //"keepalive": 120, //"ftp_passive_mode": true, //"ftp_obey_passive_host": false, //"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", //"allow_config_upload": false, }
配置完成之後儲存到預設的目錄 :D:\Sublime Text3\Data\Packages\User\sftp_servers ,檔名自己取,如果配置多個伺服器的話,比較容易區分,比如 host1Config.txt
如果配置了多個,下次在打算編輯其中某臺伺服器上的檔案時,就可以File->SFTP/FTP->Browse Server,選擇目標檔案即可
如果你想講linux上的一個完整的目錄拉倒sublime裡面,就如同開啟windows本地的檔案一樣,需要進行如下操作:
第一步:先在本地建立一個資料夾,用sublime開啟
第二步:右鍵左側sidbar中這個檔案圖示,選擇SFTP/FTP: SFTP > Map to Remote…
第三步:在彈出的配置檔案(如上)中修改相應的配置,ssh的ip,使用者名稱,密碼,想要開啟的目錄,(如上次的方法)
{ // 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", "save_before_upload": true, "upload_on_save": false, "sync_down_on_open": false, "sync_skip_deletes": false, "sync_same_age": true, "confirm_downloads": false, "confirm_sync": true, "confirm_overwrite_newer": false, "host": "123.234.345.456", //IP "user": "root", //root "password": "Guos...", //password //"port": "22", "remote_path": "/data/www/b....", //目錄資料夾路徑 "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, //"ftp_obey_passive_host": false, //"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", //"allow_config_upload": false, }
第三步:右鍵檔案圖示,SFTP > Download Folder,然後等待同步完成
(如果出錯,可能是編碼的問題,忽略掉編碼不正確的檔案,或者修改編碼)
更改完你的操作後,你可以通過右鍵目錄名,點選SFTP/FTP: Upload Folder >,即可同步到linux伺服器上。