2013年11月21日 星期四

編輯器常見問題

在vim中要移動到最靠近的大括號( brace(大括號), brackets, parenthesis )"{"
http://stackoverflow.com/questions/289342/eclipse-jump-to-closing-brace
Don't forget [{ and ]} to find the closest enclosing open or close brace. 
eclipse似乎沒有這個功能 => 用sublime的ctrl+m或ctrl+shift+m取代

vim列模式自動增加數字
安裝vim套件 VisIncr
http://vim.sourceforge.net/scripts/script.php?script_id=670
1. (vim 7.1以後版本可略)安裝 vimball
2. 下載 visincr.vba.gz
3. 安裝:(只安裝到該使用者的~/.vim 資料夾下)
$ vim visincr.vba.gz
:so %
:q
(在github上直接載源碼後解壓縮到家目錄.vim資料夾下應該有一樣效果(未試))
使用:
用ctrl+v進入列模式選取,然後:I (完成), 用:help visinrc.txt 看教學
或使用純vim的功能替換
http://wjason.iteye.com/blog/341328
1. 写一行:INSERT INTO ME.SCHEDULE(..., DATETIME, ...) VALUES(..., '2009-01-01 01:00:00.0', ...)
2. Y
3. 58p
4. gg ctrl+v G
5. :'<,'>s/2009-01-01 01:\zs\d\d\ze:/\=line(".") - line("'<") + 1
下面是这条命令中每个元素的含义:
'<,'>        我们所选中的区域 (:help '<:help '> )
s            在选中的区域中进行替换 (:help :s )
\zs          指明匹配由此开始 (:help /\zs )
\d*          查找任意位数的数字 (:help /\d )
\ze          指明匹配到此为止 (:help /\ze )
\=           指明后面是一个表达式 (:help :s\= )
line(".")    当前光标所在行的行号 (:help line() )
line("'<")   我们所选区域中第一行的行号 (:help line() ) 


eclipse中使用
With Ctrl + Shift + L you can open the "key assist", where you can find all the shortcuts.
eclipse 打開上一個關閉的分頁
http://stackoverflow.com/questions/2243561/undo-closed-tab-in-eclipse
Try Alt +  that will go backward in history - if tab is closed it will reopen it.


看vim移動相關指令
:help motion.txt


使用notepad++內建的NppFTP(可走sftp)遠端編輯
點"外掛模組"->NppFTP-> Show NppFTPWindow
點面板右上角設定圖示->Profile settings-> 新增伺服器,填入帳號、密碼-> 即可點連線圖示

notepad++書籤
http://portable.easylife.tw/205
書籤
用戶可用滑鼠點擊書籤邊行(書籤邊行位於列數邊行右方)或使用鍵盤捷徑Ctrl+F2來標明或移除書籤。使用鍵盤捷徑F2到下一個書籤或Shift+F2到上一個書籤。如欲清除所有書籤,使用選單 尋找->清除所有書籤 。

notepad++列模式自動增加數字(內建就有)
選取列 => 編輯 => 列模式編輯(熱鍵 alt+c) => 輸入要的設定


sublime 自動縮排
http://blog.lackneets.tw/2013/11/Sublime-Reindent.html
Edit > Line > Reindent
sublime設定縮排空白或tab
https://plus.google.com/108388957557258766656/posts/1HdQRLRbUUj
1. Preferences -> Settings - Default  -> ( 設定為兩個空白縮排 )
{
...
  "translate_tabs_to_spaces": true,
  "tab_size": 2,
  "detect_indentation": false, // 加了後,新檔案才不會受複製貼上的程式碼影響縮排
...
}
如果要將檔案裡的所有 tab 字元轉成 space,或是所有 space 轉為 tab 字元,可以點一下右下角的「Tab Size: X」或「Spaces: X」,然後如圖選擇需要的選項動作。( ex. C語言為兩空白縮排,在這邊設成tab縮排 )

sublime列模式自動增加數字
解法:安裝套件Text-Pastry ( 用Package Control 直接搜尋安裝 )
使用方法:
先用列模式選取你要的範圍,ctrl+alt+n後sublime下面會出現界面,輸入2 1 (2空隔1)即可 => 由2開始每次增加1
ps. Package Control 安裝方法
1. 使用ctrl+` 進入sublime的console模式
2. 貼上下列文字 ( sublime text 3適用 )
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

調整aptana 的php文件縮排距離
Preferences > Studio > Editors > PHP > Indentation. (設定Use Tabs和Tab size:4)

aptana自訂Snippet(代碼片段) => 如同Eclipse PDT 的PHP templates
Commands -> PHP -> Edit this bundle
aptana自動下載完後會在workspace的Project Explorer開專案 ex. PHP [master]
點選bundle.rb 編輯 ( https://wiki.appcelerator.org/display/tis/Creating+a+new+snippet )
snippet "Echo pre print_r" do |snip|
  snip.trigger = "epc"
  snip.expansion = "echo \"
\";\necho print_r(${1:method_name});\necho \"
\";" end snippet "echo one line" do |s| s.trigger = "epl" s.expansion = "echo \" ${1:method_name}:\".${2:method_name};" end

缺點:在html裡面也能使用...

aptana 的jquery自動完成
https://wiki.appcelerator.org/display/tis/JavaScript+Library+Support
  1. Commands > Install Bundle > jQuery
  2. Right click on a project, select Properties > Project Build Path and select the checkbox for jQuery 1.6.2.
因為github上jquery自動完成只支援到jquery1.6.2 ( https://github.com/aptana/javascript-jquery.ruble )

改用eclipse(PDT 3.8) 的jquery自動完成
https://code.google.com/a/eclipselabs.org/p/jsdt-jquery/wiki/Installation
1. 安裝jsdt-jquery  - Use the following update site URL http://svn.codespot.com/a/eclipselabs.org/jsdt-jquery/updatesite
2. 在你的PHP Explore的Project上點右鍵-> Configure -> Add jQuery
3. Add a JavaScript Library Project → Properties → JavaScript → Include Path → Libraries → Add JavaScript Library...( 我選1.9才有$.on()的提示。選1.10似乎會吃到1.1,提示的不完整 )

Eclipse Standard 4.3.2(灌PDT)使用jquery自動完成
https://code.google.com/a/eclipselabs.org/p/jsdt-jquery/wiki/Installation
直接用網址 http://svn.codespot.com/a/eclipselabs.org/jsdt-jquery/updatesite 當update site更新會遇到錯誤
解法:
必須先安裝"JavaScript Development Tools"
Comment by edward.m...@gmail.com, Feb 23, 2014
1. Complete the following steps in Eclipse to get plugins for JavaScript? files:

-.Go to "Help" -> "Install New Software" -.Select the repository for your version of Eclipse. Kepler - http://download.eclipse.org/releases/kepler -.Go to "Programming Languages" -> Check the box next to "JavaScript Development Tools" -.Click "Next" -> "Next" -> Accept the Terms of the License Agreement -> "Finish" -.Wait for the software to install, then restart Eclipse -.Once Eclipse has restarted, open "Window" -> "Preferences" -> "General" -> "Editors" -> "File Associations" -> Add ".js" to the "File types:" list, if it is not already there -.In the same "File Associations" dialog, click "Add" in the "Associated editors:" section -.Select "Internal editors" -.Select "JavaScript Viewer". Click "OK" -> "OK"

2. folow steps in this page.

Now my eclipse with JSDT works perfectly. Thanks
翻譯:
1. 先用update site: http://download.eclipse.org/releases/kepler 安裝"JavaScript Development Tools"
2. 然後在"Window" -> "Preferences" -> "General" -> "Editors" -> "File Associations" 要把.js加到"File types"裡面(這步我沒做,因為打開已經設好了)
3. 在.js下方的"Associated editors:"對話框裡面新增"Internal editors"的"JavaScript Viewer" (估計是安裝 "JavaScript Development Tools" 後才有的 )
(以下照原文步驟做)
4. Use the following update site URL http://svn.codespot.com/a/eclipselabs.org/jsdt-jquery/updatesite
5. Convert you project to a JavaScript project if it is not already one Project → Configure → Convert to JavaScript Project..
6. Add a JavaScript Library Project → Properties → JavaScript → Include Path → Libraries → Add JavaScript Library... (中間jquery勾選 No conflict後,$()好像就不會運作,只有jQuery()才會運作)
7. 完成,在js, html, php檔都能正常提示(比PDT3.8安裝的強大)


ubuntu執行eclipse 4.3.2(kepler) 出現錯誤
jvm terminated exit code 13 usr bin java ...
解法:
$ uname -a #查linux版號是64位元
上網下載64-bit的eclipse

備份eclipse 3.8 PDT 的設定到 eclipse kepler 4.3.2 ( +PDT )
http://stackoverflow.com/questions/481073/eclipse-keybindings-settings => 熱鍵和各檔案的關聯(ex. ctp用php view開)都會備份到
export all your Eclipse prefs to a file.
File->Export->General->Preferences
Import has an option to import only key settings from this file.
File->Import->General->Preferences
直接在Window->Preferences->General->Keys裡面Export出來的CSV找不到地方可以Import

sublime 英文小寫轉大寫
http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/reference/keyboard_shortcuts_win.html
1. 選取你要的文字範圍
2.
Ctrl + KU => 轉大寫
Ctrl + KL =>轉小寫

sublime安裝gosublime後出現錯誤
MarGo: Missing required environment variables: GOPATH
https://github.com/DisposaBoy/GoSublime/issues/310
解法:
Preferences -> Package Settings -> GoSublimge -> Settings – User add {"env": {"GOPATH": "$HOME/go"}}
重開sublime就不會出現錯誤提示了


eclipse mars(4.5.0) 安裝 SVN team 套件
Help -> Eclipse Marketplace -> 搜尋svn -> 直接安裝
注意:
如果svn server版本是1.8,而eclipse安裝1.7的svn套件,拉下來後無法在命令行查log(svn log)
需在 Help-> Installation Details 裡面移除重裝svn 套件





沒有留言:

張貼留言