How do I convert tabs to spaces in Notepad++?
I found a webpage that suggests it's possible, but I couldn't find any information about how to do it.
I would like to be able to do that, because some web forms don't respect code with tabs in them.
To convert existing tabs to spaces, press Edit->Blank Operations->TAB to Space
.
If in the future you want to enter spaces instead of tab when you press tab key:
- Go to
Settings->Preferences...->Language
(since version 7.1) orSettings->Preferences...->Tab Settings
(previous versions) - Check
Replace by space
- (Optional) You can set the number of spaces to use in place of a Tab by changing the
Tab size
field.
Obsolete: This answer is correct only for an older version of Notepad++. Converting between tabs/spaces is now built into Notepad++ and the TextFX plugin is no longer available in the Plugin Manager dialog.
- First set the "replace by spaces" setting in
Preferences -> Language Menu/Tab Settings
. - Next, open the document you wish to replace tabs with.
- Highlight all the text (CTRL+A).
- Then select
TextFX -> TextFX Edit -> Leading spaces to tabs or tabs to spaces
.
Note: Make sure TextFX Characters plugin is installed (Plugins -> Plugin manager -> Show plugin manager
, Installed
tab). Otherwise, there will be no TextFX menu.
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
You need to replace \t
- make sure you use extended mode!
Follow this procedure to convert spaces to tabs or vice-versa:
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.
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.
I did not read all of the answers, but I did not find the answer I was looking for.
I use Python and don't want to do find/replace or 'blank operations' each time I want to compile code...
So the best solution for me is that it happens on the fly!
Here is the simple solution I found:
Go to:
- Menu Settings -> Preferences
- Choose Tab Settings
- Choose your language type (e.g. Python)
- Select checkbox 'Use default value'
- Select checkbox 'Replace by space'
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.
CLR Tabs to Spaces plugin should be a good option. I have used it and it worked.
I follow this simple way:
- Double click (Highlight) single tab (ie: \t).
- Press
ctrl + F
(Find/repace
). - You may not see \t or single tab area on
Find What:
field. But don't worry. - Enter a
space
inReplace With:
field. - Click
Replce All
.
Done! :)
See:
Note: This method applies to reverse (Replace a space by a tab) case too.
If you happen to work in a Unix environment, the expand command is what you need:
Settings > Preferences > Tab Settings Check the "replace by space". Notice above it there is Tab size: 4 Click on the four and a window will open with the option to change the value to another integer.
Put in your desired integer and press the ENTER key.
There you have it <3.
The following way is the best way in my opinion:
Download:
- Notepad++
- The plugin http://sourceforge.net/projects/tabstospacesnpp/?source=typ
- Read the instructions and it will convert tabs to spaces.
来源:https://stackoverflow.com/questions/455037/convert-tabs-to-spaces-in-notepad