Indenting by spaces using HTMLTidy in Notepad++ - html

How do I make it so that instead of indenting my elements by multiples of 2 spaces (when formatting without wrapping is selected), HTMLTidy indents them by multiples of tabs (4 spaces long but only 1 byte in size)?

The HTML Tidy docs say that tidy never outputs tabs. But, since you're in Notepad++, you can use TextFX Edit -> Leading space to tabs to convert the spaces that HTMLTidy gives you into tabs. Just make sure that indent-spaces is set to 4 in your config file.
The location of your config file will vary depending on how you installed notepad++ and what version you have, but its path will probably look like one of these
C:\Program Files\Notepad++\plugins\NPPTextFX\tidycfg.ini
C:\Program Files\Notepad++\plugins\Config\tidy\tidycfg.ini

Related

How to find all this kind of UNICODE � in multiple html pages (or, with notepad++)? [duplicate]

I have a bizarre problem: Somewhere in my HTML/PHP code there's a hidden, invisible character that I can't seem to get rid of. By copying it from Firebug and converting it I identified it as  or 'Zero width no-break space'. It shows up as non-empty text node in my website and is causing a serious layout problem.
The problem is, I can't get rid of it. I can't see it in my files even when turning Invisibles on (duh). I can't seem to find it, no search tool seems to pick up on it. I rewrote my code around where it could be, but it seems to be somewhere deeper in one of the framework files.
How can I find characters by charcode across files or something like that? I'm open to different tools, but they have to work on Mac OS X.
You don't get the character in the editor, because you can't find it in text editors. #FEFF or #FFFE are so-called byte-order marks. They are a Microsoft invention to tell in a Unicode file, in which order multi-byte characters are stored.
To get rid of it, tell your editor to save the file either as ANSI/ISO-8859 or as Unicode without BOM. If your editor can't do so, you'll either have to switch editors (sadly) or use some kind of truncation tool like, e.g., a hex editor that allows you to see how the file really looks.
On googling, it seems, that TextWrangler has a "UTF-8, no BOM" mode. Otherwise, if you're comfortable with the terminal, you can use Vim:
:set nobomb
and save the file. Presto!
The characters are always the very first in a text file. Editors with support for the BOM will not, as I mentioned, show it to you at all.
If you are using Textmate and the problem is in a UTF-8 file:
Open the file
File > Re-open with encoding > ISO-8859-1 (Latin1)
You should be able to see and remove the first character in file
File > Save
File > Re-open with encoding > UTF8
File > Save
It works for me every time.
It's a byte-order mark. Under Mac OS X: open terminal window, go to your sources and type:
grep -rn $'\xFEFF' *
It will show you the line numbers and filenames containing BOM.
In Notepad++, there is an option to show all characters. From the top menu:
View -> Show Symbol -> Show All Characters
I'm not a Mac user, but my general advice would be: when all else fails, use a hex editor. Very useful in such cases.
See "Comparison of hex editors" in WikiPedia.
I know it is a little late to answer to this question, but I am adding how to change encoding in Visual Studio, hope it will be helpfull for someone who will be reading this sometime:
Go to File -> Save (your filename) as...
And in File Explorer window, select small arrow next to the Save button -> click Save with Encoding...
Click Yes (on Do you want to replace existing file dialog)
And finally select e.g. Unicode (UTF-8 without signature) - that removes BOM

Converting spaces to tabs in multiple files Sublime Text 2

Is there any way to convert all spaces to tabs, not file by file?
If I open a file and go through View => Indentation => Convert Indentation to Tabs, it only changes this file. I want to convert indentations to tabs in a whole project.
Use search and replace in multiple files to convert n spaces to tabs in select files.
First open find in files panel, cmd + shift + f, by default to find and replace in multiple files. Next define a regular expression to match spaces as tabs eg {4} (make sure you set Regular Expressions in the panel) for 4 spaces and replace with \t in desired files. Change {4} to however many spaces are being used for indentation.
As mentioned in comments to match spaces at the start of a line you can use the regexp ^( {4})+

How do I make custom snippets for Sublime Text 2 that use the same indentation as the current file?

Different projects can use different indentation styles (2-4 spaces, tabs) and I want my custom snippets to follow the style of the current file. The built-in Ruby snippets does this but my custom snippets retain the indentation of the snippet. I checked the docs and found the predefined variables:
$TM_SOFT_TABS YES if translate_tabs_to_spaces is true, otherwise NO.
$TM_TAB_SIZE Spaces per-tab (controlled by the tab_size option).
But I can't really see how to make use of those to control which indents to use.
Just use the tab character for indents in snippet files. Sublime Text will automatically convert them to the correct indentation style for the current file.

Is there a increaseIndentPattern in Sublime Text?

I'm trying to add auto increate indentation feature in a Sublime Text package.
As for TextMate, there's increaseIndentPattern = '\{'; that can make easy indentation.
http://manual.macromates.com/en/appendix#indentation_rules
How can I do that in SUblime Text?
Sublime Text 2 already has easy indentation built in.
Hit Ctrl+] to indent right, and Ctrl+[ to indent back or remove indentation.
Similarly, you can select the text you want to indent, and hit the Tab key. This indents the selected block of text. Shift+Tab will remove indentation of selected text.
If you are working with predefined syntaxes you can define a keybinding for your "ReIndent" command, which will execute Edit>Line>Reindent command on the entire document.
However, if you reeeeally want to get your hands dirty with setting up how the program indents specific language syntaxes, you go to the Preferences Menu and hit Browse Packages.
Look for the language you want to modify indentation rules for, I'll use PHP as an example. There are 2 files that have indentation rules for my copy of PHP right now. Their names are as follows:
Indentation Rules Annex.tmPreferences
Indentation Rules.tmPreferences
There should be another copy of these same filenames with *.cache at the end. Feel free to add .old after .cache and modify the plain *.tmPreferences ones.

Easily clean-up HAML spacing in TextMate

I'm liking HAML but running into annoyances with tabs vs spaces. Is there an easy way to convert a file from one to the other in TextMate?
I prefer tabs but I'm seeing spaces used alot...wondering if that's preferred or if that's an artifact of code I've seen posted to the web?!? I don't really care though it would seem, to me, that tabs would be simpler to work with...
It's as simple as this: Text > Convert > Spaces to Tabs
I prefer tabs over spaces too (as long as they are size of 2 spaces).
Edit:
Textmate 2: 'Bundles > Source > Convert Tabs to Spaces'
Shortcut: ⌃⇧⌘T (ctrl + shift + cmd + t)
Now I'm all in for spaces with soft tabs always on ;)
I have a macro that I wrote to convert tabs in spaces, and another one for spaces to tabs:
Just start a macro recording, do a Find and Replace (with Replace all) finding (tabs or spaces) and replacing with (the other one).