Tuesday, May 28, 2013

How to change Eclipse to use spaces instead of tabs



For the default text editor:
  • General > Editors > Text Editors > Insert spaces for tabs (check it)
For PHP:
  • PHP > Code Style > Formatter > Tab policy (choose "spaces")
  • PHP > Code Style > Formatter > Indentation size (set to 4)
For CSS:
  • Web > CSS > Editor > Indent using spaces (select it)
  • Web > CSS > Editor > Indentation size (set to 4)
For HTML:
  • Web > HTML > Editor > Indent using spaces (select it)
  • Web > HTML > Editor > Indentation size (set to 4)
For XML:
  • XML > XML Files > Editor > Indent using spaces (select it)
  • XML > XML Files > Editor > Indentation size (set to 4)
For Javascript:
  • Javascript > Preferences > Code Style > Formatter > Edit > Indentation (choose "spaces only")
  • Rename the formatter settings profile to save it
For Java:
  • Java > Preferences > Code Style > Formatter > Edit > Indentation (choose "spaces only")
  • Rename the formatter settings profile to save it

To search for all the tabs in eclipse.
Search > File > search for containing text "\t" and select Regular expression > Search

To replace tab with spaces
Search > File > search for containing text "\t" and select Regular expression > Replace > Enter 4 spaces.

Wednesday, May 1, 2013

Regular Expression


Lookahead

  • q(?=u)  : quit
  • q(?!u)  : qtip  not quit


LookBehind

  • (?<=a)b  :  abc
  • (?<!a)b  :  xbc not ab



  • ^ matches at the start of the string
  • $ matches at the end of the string
  • \d matches a single character that is a digit
  • \w matches a "word character" (alphanumeric characters plus underscore)
  • \s matches a whitespace character
  • The dot matches a single character, except line break characters. It is short for [^\n] (UNIX regex flavors) or[^\r\n] (Windows regex flavors).gr.y matches graygreygr%y, etc.