The search & replace is good if you just want to strip tabs, but often I find that I would like to replace tabs in existing text (code written by someone else with different tab size) with the equivalent number of spaces to line things up. THAT, I have not yet found a way to do within the tool.
The TextFX plug-in has an option to convert /leading/ tabs back and forth to spaces, (haven't gotten it to work, but I'm sure it must be me) but I've seen nothing to deal with tabs that are not leading white space.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This will read tabwidth and Replace by Space under Settings-Tab Settings and perform the proper conversion of leading whitespace, destroying any non tabwidth multiples of spaces. If a lifetime of horrible editors has trained you to use spaces because tab handling and conversion is so bad, you can train yourself to use tabs by turning on [x]Autoconvert typed leading spaces to tabs and when ever you enter enough spaces, a tab will be substituted in their place. You will need to show Whitespace and Tabs if you want to see this in action. You must have Replace by Space unchecked for this conversion to take place.
The command is near the top of the Edit submenu, past the first separator..
HTH
CChris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well... Either the find and replace is useful... You can enable the extended search, search for \t and replace it with how many space you want! Really simple :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem with search & replaces \t with some number of spaces is that it indiscriminately replaces the tabs with a fixed number of spaces every time. If a line contains one or more tab characters being used to "line things up" in the code, this will make a mess of things as some of the tabs are "partial".
For example (tabs set at 5 in N++):
[code]
...
l_num1 NUMBER(10,2) := NULL;
l_somestringthing VARCHAR2(256) := NULL;
l_tbl_row ABC.TABLE_XYZ%ROWTYPE := NULL;
...
[/code]
Now, if you blindly replace all tabs with 5 spaces, it won't line up at all. The number of spaces each "interior" tab should be replaced with depends on the tab setting and where the last non-tab leading it is in relation to a number evenly divisible by that tab setting. You need a replacement algorithm that is a tad bit smarter.
I would love to see a way to do that easily and reliably, and importantly - only on selected text. (even in column-mode). It would be nice to be able to do the same in the other direction also - spaces back to tabs.
-Bill
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Imagine the previously posted code with sufficient tabs between each component of the declaration and initialization to line up the data types, and the := on each line.
-Bill
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The same question was posed to Stack Overflow, but there was no answer there either. Meanwhile, I found a nice app that seems to do the job. It's called CLR Tabs to Spaces, and works like a charm :) Maybe I'll email the tool's creator and suggest him to make a notepad++ plugin out of it :D
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
Hi!
Just a simple question. How to convert tabs to spaces in Notepad++? I have version 5.0.3 of Notepad++ installed to my computer.
The use of tab vs spaces for indent is controlled by the Settings -> Preferences -> Edit Component -> Tab setting frame.
Regarding conversion of existing text, you can use replacement of \t by a few spaces in extended mode.
CChris
The search & replace is good if you just want to strip tabs, but often I find that I would like to replace tabs in existing text (code written by someone else with different tab size) with the equivalent number of spaces to line things up. THAT, I have not yet found a way to do within the tool.
The TextFX plug-in has an option to convert /leading/ tabs back and forth to spaces, (haven't gotten it to work, but I'm sure it must be me) but I've seen nothing to deal with tabs that are not leading white space.
Hi,
I am tremendously missing a "convert tabs to spaces" - function, too.
I was certain there was one in TextFX, but I can't find it... Weird.
But I agree that would be nice to have.
How about search and replace?
Quote from TextFX docs:
**Demo: convert leading spaces or tabs to ...
This will read tabwidth and Replace by Space under Settings-Tab Settings and perform the proper conversion of leading whitespace, destroying any non tabwidth multiples of spaces. If a lifetime of horrible editors has trained you to use spaces because tab handling and conversion is so bad, you can train yourself to use tabs by turning on [x]Autoconvert typed leading spaces to tabs and when ever you enter enough spaces, a tab will be substituted in their place. You will need to show Whitespace and Tabs if you want to see this in action. You must have Replace by Space unchecked for this conversion to take place.
The command is near the top of the Edit submenu, past the first separator..
HTH
CChris
Well... Either the find and replace is useful... You can enable the extended search, search for \t and replace it with how many space you want! Really simple :-)
The problem with search & replaces \t with some number of spaces is that it indiscriminately replaces the tabs with a fixed number of spaces every time. If a line contains one or more tab characters being used to "line things up" in the code, this will make a mess of things as some of the tabs are "partial".
For example (tabs set at 5 in N++):
[code]
...
l_num1 NUMBER(10,2) := NULL;
l_somestringthing VARCHAR2(256) := NULL;
l_tbl_row ABC.TABLE_XYZ%ROWTYPE := NULL;
...
[/code]
Now, if you blindly replace all tabs with 5 spaces, it won't line up at all. The number of spaces each "interior" tab should be replaced with depends on the tab setting and where the last non-tab leading it is in relation to a number evenly divisible by that tab setting. You need a replacement algorithm that is a tad bit smarter.
I would love to see a way to do that easily and reliably, and importantly - only on selected text. (even in column-mode). It would be nice to be able to do the same in the other direction also - spaces back to tabs.
-Bill
OK - that example didn't work.
Imagine the previously posted code with sufficient tabs between each component of the declaration and initialization to line up the data types, and the := on each line.
-Bill
The same question was posed to Stack Overflow, but there was no answer there either. Meanwhile, I found a nice app that seems to do the job. It's called CLR Tabs to Spaces, and works like a charm :) Maybe I'll email the tool's creator and suggest him to make a notepad++ plugin out of it :D
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.
https://sourceforge.net/projects/tabstospacesnpp/