Easily clean-up HAML spacing in TextMate - html

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).

Related

Linebreaks in middle of URL in HTML

I have this strange issue, where I get random linebreaks in my HTML when I copy & paste links from mails I get.
The problem is, linebreaks look exactly like any other whitespace and on long lines I have problems seeing if there is any linebreaks.
Normally this wouldn't be a problem, but we are also using emailing system that doesn't like breaklines in middle of an element.
Is there a way to see these without manually scanning all the lines, which is impossible due to amount of mails we are sending.
Regex maybe?
I'm using Notepad++ as an editor.
In Notepad++, you can use "Extended" mode in the FIND Option. Use "\r\n" to scan all the new lines in the file. Use "\r" to find all carriage returns in the file.

How can I insert a return at every HTML break "> <"

So I've never encountered this personally - I have a huge blob of HTML with inline CSS that I need to break up to be cohesive and editable (it's literally all back to back right now with no returns in any of the lines).
I use Sublime and I'm trying to insert a return at every break of code so I can easily go through and edit it all.
If you do not have a lot of code you can do it manually.
Otherwise just select all lines (Ctrl A) and then from the menu select Edit → Line → Reindent. This works with any files with the file extension .php or .html.

Can't figure out a regex with line break - HTML

I have written a very simple regular expression to search within an HTML document for any tag - as we are modifying 40+ templates that have been edited by a WYSIWYG editor that was horrible. Basically, it added style="font... tags everywhere - so I want to delete them all.
The problem is, some of them have line breaks between the styles (like you would typically write CSS) - and I can't figure out how to include line breaks within my expression.
Here is what I have:
style="font(.*?)"
I am using textmate to search for it, and it works great except for styles that have hard line breaks in them.
Any help???
Use this RegEx: style="font([\s\S]*?)". . does not match \n by default.
Putting (?s) at the front of your regex causes . to match newline as well
This is the most straightforward way to do it:
style="font([^"]*)"

Format Code In MonoDevelop

I am using MonoDevelop on Mac to write MonoTouch apps. Automatica code indenting/formatting works great while I am typing.
The problem is that when I copy and paste code snippets, in many cases I lose the formatting and lines are combined together, indenting is lost, and it is a huge pain to implement the tabs, spacing, and line breaks manually. Is there anyway I can use a command in monoDevelop to automatically indent and apply the formatting to existing code.
I thought maybe Edit|Format|Format Document/Selection would work, but these commands don't have any affect on the code at all.
Any help?
To format the entire document in one keystroke: control-I
To format a selection: Edit->Format->Format Selection
To customize the formatting: MonoDevelop->Preferences->Source Code->Code Formatting
You actually need to select all your text, and then go to Edit->Format->Format Document. It doesn't seem to work otherwise.
For me on macOS, the shortcut for "auto-format" is CTRL + i.
You can change the shortcut if you want. To change it, go to Preferences -> Key Bindings, then type "format" in the search box and edit the "Format Document" shortcut/key binding.

Indenting by spaces using HTMLTidy in Notepad++

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