Thursday, April 21, 2011

eclipse: changing the # of spaces to indent/unindent

How do I adjust the # of spaces added/removed by Eclipse when I hit Tab or Shift+Tab, for a given filetype? I am working on reStructuredText files (.rst) and want 2 spaces for those instead of 4.

From stackoverflow
  • From the Window menu, choose Preferences. Navigate down to General: Editors: Text Editors: Displayed tab width.

    You may also want to check out the code style for some other types of editors, because they decide whether to use tabs or spaces, and the size of the tab stops.

    Hint: In the top left of the preferences dialog, you can type "tab" where it says "type filter text", and it will show you all settings related to tabs.

    Jason S : neat. is there a way to do it on a per-file-type basis?
    Don Kirkby : Not sure. You can change it for a specific project. You can also associate a particular editor with the .rst file type. My set of plug ins includes separate tab settings for C, Java, HTML, JavaScript and XML editors. If you're not using one of those for anything else, you could associate it with .rst and set the tab width to 2. You might also want to check out the AnyEdit plug in, I seem to remember it had a bunch of options.

0 comments:

Post a Comment