• Edit
  • Delete

Eclipse cheat sheet (using pdt & symfony)

http://eclipsesource.com/blogs/2013/08/13/eclipse-preferences-you-need-to-know/

Subversion

Conflict handling

  • right click on the original file (not on myFile.mine or myFile.r123) and select "team -> edit conflicts"
  • (a two column diff editor opens)
  • all changes are resolved from the right side ("theirs") to the left side
  • non-conflicting changes are marked blue, conflicts are marked red
  • manualy resolve the conflicts (you can use the "arrow icons in the right top of the window", or click on the small sqares in the middle of the two columns)
  • save
  • right click on the original file and select "team -> Mark resolved"
  • submit

Merging

Example: merge an update (r123) in the trunk into a development branch

  • select the working copy where you want implement the changes (branch)
  • explorer: right click on the project -> team -> merge
  • From: enter the source URL (trunk)
  • From revision: enter the revision number before the last change was made (r122)
  • To: use "From:" URL
  • To revision: enter the revision where the last change was made (r123)
  • Click "unified diff" to verify the result
  • "Merge"

Miscellaneous

Find/Replace with regular expressions (regex)

Helpful to create the expression: https://regexr.com

Example: remove all function calls of utf8_decode(otherstuff("foobar"))

  • Find: utf8_decode\(([^)]+)\)
  • Replace with: $1
  • Options - Regular expression: check

Find matching brackets/braces

  • CtrlP

Split screen horizontally

  • Ctrl + _

Code completion / templates

  • In the editor: hit [CTRL]-[SPACE]

 

Show whitespace characters

  • right click in an empty area of the icon toolbar at the top -> customize perspective
  • tab "commands" -> check "Editor Presentation"

 

Show hidden files in the explorer

  • click on the small "down" arrow in the top left corner of the explorer -> Filters
  • uncheck "*.files"

Manual php type hints

Just add this line in your code:

$url = $helper->get('url');
/*@var $url sfUrlHelper*/ 

Templates

Code templates are especially handy in MVC "view" templates, like symfony templates.

Example for if/elseif/else:

  • In the main menu:
  • Window -> Preferences
  • Web and XML -> HTML Files -> Templates
  • Click "New"
  • Name: "php if"
  • Description "php if/elseif/else/endif"
  • Pattern:
    • <?php if(${dollar}${expression}): ?>
          ${cursor};
      <?php elseif(${dollar}${expression2}): ?>
      
      <?php else: ?>
      
      <?php endif; ?>
  • Usage in the editor: hit [CTRL]-[SPACE] and select "php if" from the menu

Problem: Slow startup / indexing or much disk-space used

Solution: go to workspace/.metadata/plugins/org.eclipse.dltk.core.index.sql.h2 and delete the *.db files.
These are cache files which are rebuilt upon the next eclipse startup. Sometimes the are corrupted.

Reference: http://www.nwiresoftware.com/blogs/nwire/2010/09/five-tips-speeding-eclipse-pdt-and-nwire

Charset / Encoding Detect Plugin

Note: both are not really working for autodetect:

https://marketplace.eclipse.org/content/file-encoding-info
https://raw.githubusercontent.com/ystsoi/eclipse-fileencodinginfo/master/update/1.4.0

https://marketplace.eclipse.org/content/file-encoding-info
https://cypher256.github.io/eclipse-encoding-plugin/

Use cp1250

Go to Window > Pereferences > General > Workspace Type cp1250 into the dropdownbox (if not in the list, your have to type it!!)