Does anyone know how to convert tabs to spaces in Notepad++? I found a webpage that suggests it's possible (http://www.texteditors.info/notepad-replacements-compared.php) but I couldn't find any information about how to do it. I like to be able to do that because some web forms don't respect code with tabs in it.
Settings ->
Preference ->
Edit Components (tab) ->
Tab Setting (group) ->
Replace by space
In version 5.6.8 (and above):
Settings ->
Preferences... ->
Language Menu/Tab Settings ->
Tab Settings (group) ->
Replace by space
First set the "replace by spaces" setting in Preferences. Next, open the document you wish to replace tabs with Highlight all the text Then select TextFX -> TextFX Edit -> Leading spaces to tabs or tabs to spaces
There is no 'Edit Components' tab in the preferences setup. You need to go 'Language Menu/Tab Settings', there is an option in there to control tab behavior. You can even set it to work differently depending on the language of the file.
None of the presented solutions work in a more general situation where the tabs are NOT the first characters on a line.
the easy way:
- highlight a single tab area
- copy
- bring up find/replace
- paste into the find field
- click into the replace field and hit the space bar
- then replace all.
Since I can't comment on other replies atm, I'll add my own here: All the answers telling how to replace tabs with spaces -- no matter how sophisticated the methods -- are something that good old Notepad could achieve easily (just follow the steps on matt lohkamp's reply). I would expect Notepad++ to have more advanced capabilities and be able to replace tabs in the middle of lines, as many people have commented on this thread. I hope someone comes up with a real solution; otherwise this question would be generic, applying to any text editor, not only to Notepad++.
edit: I just tried two programs after searching google. The first one (bluefive.pair.com/tabs2spaces.htm) was crap (it simply does that basic replacement even Notepad can do). The second one, though, worked like a charm. It's called CLR Tabs to Spaces and it handles middle-line tabs perfectly. I'll suggest the maker to convert it into a Notepad++ plugin :)
edit 2: I guess I overlooked a feature in tabs2spaces: the Fixed Layout Formatting mode seems to make it work more or less as expected; however, it is still less flexible than "CLR Tabs to Spaces", since the latter allows the user to change the amount of spaces per tab. By the way, after contacting the tool's developer, he quickly made a npp plugin out of it (as he has announced on this thread himself), so make sure to try it out!
" The second one, though, worked like a charm. It's called CLR Tabs to Spaces and it handles middle-line tabs perfectly. I'll suggest the maker to convert it into a Notepad++ plugin :) " <<
Did you check the recency of this tool? Refer to the revision history...
" edit: I just tried two programs after searching google. The first one* was crap (it simply does that basic replacement even Notepad can do). " >>
I just can't believe it! Who would write such a tool...
Did you in fact check the documentation, a short and simple readme text file?
Did you check Fixed Layout Formatting? Did you? It may get results more to your liking. This is said to "work more or less intelligently".
[edit] I guess it is what you are after. In Fixed Layout Formatting mode it replaces Tabs by the correct number of spaces to get to the next Tab Stop. Currently, this mode uses Tab Stops set at a fixed distance of 8 characters. But this is likely to be changed in the near future. It may help you, however, to get started.
If 8 is not the desired number, you could do an additional replacement of each 8 space characters by the correct number. You would then be only left with strings of 7 or less consecutive space characters, which may need to be cut off or extended. [/edit]
By the way, this utility is way more recent and is freeware. Perhaps you could write this author also to get any additional features you would want.
i just posted a notepad++ plugin to convert tabs to spaces. yes, it converts tabs in the middle of a line. yes, it takes into account other characters within the tabbed field. check it out.
TABS2Spaces RC 1.05 is out now. It includes the desired functionality.