Sunday, January 26, 2014

Phím tắt hữu ích trong Eclipse

Trong hàng loạt các phím tắt của Eclipse hỗ trợ, mình thấy có một số các phím tắt sau mà mình thường xuyên dùng và hữu dụng trong việc code như sau:

Ctrl + B : Build project

Ctrl + Shift + B: Đặt Bug, cái này thường xuyên dùng tới, bỏ đặt bug thì nhấn thêm lần nữa

Ctrl + D : Xóa dòng tại chứa con trỏ (thường là khi có nhiều dòng trống quá, ta muốn kéo code lên gom lại nhìn cho đẹp code)

Ctrl + F : Tìm chuỗi trong class

Ctrl + H : Mở nhanh màn hình search

Ctrl + Shift + O : Tự động import

Ctrl + Shift + C : Comment, uncomment một đoạn code

Ctrl + Shift + F : Định dạng format code cho đẹp

Alt + Shift + S, V : Override hoặc implement một hàm

Alt + Shift + S, V : Override hoặc implement một hàm

Alt + Shift + S, R : Tạo hàm getter, setter cho field trong class

Alt + Shift + S, C : Tạo hàm khởi tạo bằng cách override hàm khởi tạo lớp cha

Alt + Shift + S, O : Tạo hàm khởi tạo bằng các field trong class

Ngoài ra bạn nào muốn làm cao thủ phím tắt thì thực hành nhiều lần trong project các phím tắt dưới đây của Eclipse ban hành

1. Manage Files and Projects
Ctrl+N   Create new project using the Wizard
Ctrl+Alt+n           Create new project, file, class, etc.
Alt+f, then .        Open project, file, etc.
Ctrl+Shift+r         Open Ressource (file, folder or project)
Alt+Enter             Show and access file properties
Ctrl+s    Save current file
Ctrl+Shift+s        Save all files
Ctrl+w   Close current file
Ctrl+Shift+w       Close all files
F5           Refresh content of selected element with local file system
 up
 minus2. Editor Window
Focus/ cursor must be in Editor Window for these to work.
F12         Jump to Editor Window
Ctrl+Page Down/Ctrl+Page Up   Switch to next editor / switch to previous editor
Ctrl+m  Maximize or un-maximize current Editor Window (also works for other Windows)
Ctrl+e    Show list of open Editors. Use arrow keys and enter to switch
Ctrl+F6/Ctrl+Shift+F6     Show list of open Editors. Similar to ctrl+e but switches immediately upon release of ctrl
Alt+Arrow Left/Alt+Arrow Right                Go to previous / go to next Editor Window
Alt+-      Open Editor Window Option menu
Ctrl+F10               Show view menu (features available on left vertical bar: breakpoints, bookmarks, line numbers, …)
Ctrl+F10, then n                Show or hide line numbers
Ctrl+Shift+q        Show or hide the diff column on the left (indicates changes since last save)
 up
 minus3. Navigate in Editor
Home/End          Jump to beginning / jump to end of indention. Press home twice to jump to beginning of line
Ctrl+Home/End                Jump to beginning / jump to end of source
Ctrl+Arrow Right/Arrow Left       Jump one word to the left / one word to the right
Ctrl+Shift+Arrow Down/Arrow Up           Jump to previous / jump to next method
Ctrl+l     Jump to Line Number. To hide/show line numbers, press ctrl+F10 and select 'Show Line Numbers'
Ctrl+q    Jump to last location edited
Ctrl+./Ctrl+,        Jump to next / jump to previous compiler syntax warning or error
Ctrl+Shift+p        With a bracket selected: jump to the matching closing or opening bracket
Ctrl+[+]/Ctrl+- on numeric keyboard       Collapse / Expand current method or class
Ctrl+[/]/Ctrl+* on numeric keyboard      Collapse / Expand all methods or classes
Ctrl+Arrow Down/Ctrl+Arrow Up             Scroll Editor without changing cursor position
 up
 minus4. Select Text
Shift+Arrow Right/Arrow Left    Expand selection by one character to the left / to the right
Ctrl+Shift+Arrow Right/Arrow Left           Expand selection to next / previous word
Shift+Arrow Down/Arrow Up     Expand selection by one line down / one line up
Shift+End/Home              Expand selection to end / to beginning of line
Ctrl+a    Select all
Alt+Shift+Arrow Up        Expand selection to current element (e.g. current one-line expression or content within brackets)
Alt+Shift+Arrow Left/Arrow Right            Expand selection to next / previous element
Alt+Shift+Arrow Down  Reduce previously expanded selection by one step
 up
 minus5. Edit Text
Ctrl+c/Ctrl+x/Ctrl+v        Cut, copy and paste
Ctrl+z    Undo last action
Ctrl+y    Redo last (undone) action
Ctrl+d    Delete Line
Alt+Arrow Up/Arrow Down        Move current line or selection up or down
Ctrl+Alt+Arrow Up / Ctrl+Alt+Arrow Down /        Duplicate current line or selection up or down
Ctrl+Delete         Delete next word
Ctrl+Backspace Delete previous word
Shift+Enter         Enter line below current line
Shift+Ctrl+Enter               Enter line above current line
Insert    Switch between insert and overwrite mode
Shift+Ctrl+y        Change selection to all lower case
Shift+Ctrl+x        Change selection to all upper case
 up
 minus6. Search and Replace
Ctrl+f     Open find and replace dialog
Ctrl+k/Ctrl+Shift+k          Find previous / find next occurrence of search term (close find window first)
Ctrl+h    Search Workspace (Java Search, Task Search, and File Search)
Ctrl+j/Ctrl+Shift+j            Incremental search forward / backwards. Type search term after pressing ctrl+j, there is now search window
Ctrl + Shift + o    Open a resource search dialog to find any class
 up
 minus7. Indentions and Comments
Tab/Shift+Tab   Increase / decrease indent of selected text
Ctrl+i     Correct indention of selected text or of current line
Ctrl+shift+f         Autoformat all code in Editor using code formatter
Ctrl+/    Comment / uncomment line or selection ( adds '//' )
Ctrl+Shift+/        Add Block Comment around selection ( adds '/... */' )
Ctrl+Shift+          Remove Block Comment
Alt+Shift+j          Add Element Comment ( adds '/** ... */')
 up
 minus8. Editing Source Code
Ctrl+Space          Opens Content Assist (e.g. show available methods or field names)
Ctrl+1    Open Quick Fix and Quick Assist
Alt+/      Propose word completion (after typing at least one letter). Repeatedly press alt+/ until reaching correct name
Ctrl+Shift+Insert              Deactivate or activate Smart Insert Mode (automatic indention, automatic brackets, etc.)
 up
 minus9. Code Information
Ctrl+o    Show code outline / structure
F2           Open class, method, or variable information (tooltip text)
F3           Open Declaration: Jump to Declaration of selected class, method, or parameter
F4           Open Type Hierarchy window for selected item
Ctrl+t     Show / open Quick Type Hierarchy for selected item
Ctrl+Shift+t         Open Type in Hierarchy
Ctrl+Alt+h           Open Call Hierarchy
Ctrl+u    Find occurrences of expression in current file
Ctrl+move over method               Open Declaration or Implementation
 up
 minus10. Refactoring
Alt+Shift+r          Rename selected element and all references
Alt+Shift+v         Move selected element to other class or file (With complete method or class selected)
Ctrl+Shift+c        Change method signature (with method name selected)
Alt+Shift+m        Extract selection to method
Alt+Shift+l           Extract local variable: Create and assigns a variable from a selected expression
Alt+Shift+i           Inline selected local variables, methods, or constants if possible (replaces variable with its declarations/ assignment and puts it directly into the statements)
 up
 minus11. Run and Debug
Ctrl+F11               Save and launch application (run)
F11         Debug
F5           Step Into function
F6           Next step (line by line)
F7           Step out
F8           Skip to next Breakpoint
 up
 minus12. The Rest
Ctrl+F7/Ctrl+Shift+F7     Switch forward / backward between views (panels). Useful for switching back and forth between Package Explorer and Editor.
Ctrl+F8/Ctrl+Shift+F8     Switch forward / backward between perspectives
Ctrl+p    Print
F1           Open Eclipse Help

Tổng hợp phím tắt hữu ích trong Visual Studio 2008, 2010, 2011, 2012

Shortcut keys play an important role to increase the output. Developers work at least 6 to 8 hours on daily basis on Visual Studio. If the developer knows the shortcut keys, he can keep away from using of mouse and absolutely it will enhance productivity and reduce headache to use of mouse again and again. I am sharing some interesting and useful shortcut keys to work with Visual Studio. For visual studio top shortcuts refer the article Top 10 Visual Studio Keyboard Shorcuts.


General Shortcut Keys


Shortcut


Description


Ctrl-X or Shift-Delete or Ctrl-L


Cuts entire line or Cuts the currently selected item to the clipboard


Ctrl-Del


Delete next "word"


Ctrl-C or Ctrl-Insert


Copies the currently selected item to the clipboard


Ctrl-V or Shift-Insert


Pastes the item from the clipboard at the cursor location


Ctrl-Z or Alt-Backspace


Undo the previous editing action


Ctrl-Space


To see intelligence dialog


Ctrl-Y or Ctrl-Shift-Z


Redo the previous undo action


Ctrl-S


Saves the current selected file


Ctrl-Shift-S


Saves all files and projects


Ctrl-P


Displays the Print dialog


F7


Switches from the design view to the code view in the editor


Shift-F7


Switches from the code view to the design view in the editor


Shift-F8 or F8


Navigate to compile time errors


Alt-Shift-A


Add Existing Item(file) to selected project


Ctrl-Shift-A


Add New Item(file) to selected project


Shift-F9


Display the selected item quick output means contains value while debugging


F12


Moves the cursor to the selected method, variable, class definition.


Shift-F12


Finds the reference to the selected method, variable, class or the item under the cursor


Ctrl-}


Match curly braces, brackets or compiler directives


Ctrl-Shift-}


Select text between matched braces, brackets or compiler directives


Text manipulation


Shortcut


Description


Tab


Indents the currently selected line or lines by one tab stop. If there is no selection, this inserts a tab stop


Tab-Tab


Complete the syntax of an item. Example- Write for and now press Tab-Tab, then for loop syntax will be automatically completed. Similarly it works for property, index, class syntax.


Shift-Tab


Moves current line or selected lines one tab stop to the left


Backspace or Shift-Backspace


Deletes one character to the left of the cursor


Ctrl-K, Ctrl-C


Marks the current line or selected lines of code as a comment, using the correct comment syntax for the programming language


Ctrl-K, Ctrl-U


Removes the comment syntax from the current line or currently selected lines of code


Ctrl-K, Ctrl-D


Do proper alignment of all the code of design view and code view


Ctrl-T or Shift-Enter


Swaps the characters on either side of the cursor. (For example, AC|BD becomes AB|CD.) Available only in text editors


Ctrl-U


Changes the selected text to lowercase characters


Ctrl-Shift-U


Changes the selected text to uppercase characters


Ctrl-Shift-Right Arrow


Select the entire word with space from start to end


Ctrl-Right Arrow


Move the cursor in forward direction word by word


Shift-End


Select the entire line from start to end


Shift-Home


Select the entire line from end to start


Shift-Alt-Arrows or Alt-Mouse


Column wise text selection for text manipulation


Ctrl-Delete


Deletes the word to the right of the cursor


Ctrl-Backspace


Deletes the word to the left of the cursor


Ctrl-G


Jump to line number or go to line


Project related


Shortcut


Description


Ctrl-Shift-B


Builds the solution


Ctrl-N


Displays the New File dialog. Note: files created this way are not associated with a project. Use Ctrl-Shift-A to add a new file in a project


Ctrl-Shift-N


Displays the New Project dialog


Ctrl-O


Displays the Open File dialog


Ctrl-Shift-O


Displays the Open Project dialog


Ctrl-M-O


Collapse all the methods, classes, regions in the current code behind or class file


Ctrl-M-P or Ctrl-M-L


Expands all the methods, classes, regions in the current code behind or class file


Ctrl-F


Displays the Find dialog


Ctrl-H


Displays the Replace dialog


Ctrl-Shift-F


Find the reference of selected item into entire solution.


Ctrl-Tab


Move from one opened file to another opened file in visual studio.


F9


Sets or removes a breakpoint at the current line


Ctrl-F9


Enables or disables the breakpoint on the current line of code. The line must already have a breakpoint for this to work


F5


Runs the code with invoking the debugger.


Ctrl-F5


Runs the code without invoking the debugger.


F4 or Alt-Enter


Displays the Properties window, which lists the design-time properties and events for the currently selected item


Ctrl-Alt-S


Displays the Server Explorer window, which allows you to view and manipulate database servers, event logs, message queues, web services, and many other operating system services


Ctrl-Alt-L


Displays the Solution Explorer, which lists the projects and files in the current solution


Ctrl-Alt-X


Displays the Toolbox, which contains controls and other items that can be dragged into editor and designer windows


Ctrl-Alt-I


Displays the Immediate window, where you can find the controls or variables values or can do data manipulation during debugging