I'm not sure what the correct definition for this is, but here is what I am trying to do:
I am trying to remove (delete) the empty space or move the cursor to the beginning of the next HTML tag in an existing HTML document, that sort of looks like the examples below:
With the cursor immediately after the first <p> tag: By pressing Alt-Shift-del (not backspace) deletes all space up until the text "this" in Code Example A:, but in Example B: we delete only one line of text, and has to press it twice, in Example C: we end up deleting all the space including the first < in <code>
With the cursor immediately after the end of the paragraph text block ('text'/'tag'): By pressing Alt-Shift-del here, deletes as above, but also deletes the </ of the closing tag.
I do not know if this is an issue to do with some hidden characters/spaces/tabs in the files I am working with, or whatever, but it is irritating.
So, is there some way that this behaviour can be changed ??? Hidden prefs in a .plist file ?
IF not - or as an immediate alternative - how would I create a regex & Macro that would delete all the space (including tabs, new lines, carriage returns etc ) up until the first < tag ??
I would be very grateful if someone could point me in the right direction here.
Example A: <p> this is a simple paragraph text </p>
Example B: <p> this is a simple paragraph text </p>
Example C: <p> <code>this</code> paragraph begins with an html tag </p>
Kind regards,
Mats
On Nov 23, 2004, at 11:48, Mats Persson wrote:
So, is there some way that this behaviour can be changed ??? Hidden prefs in a .plist file ?
You can add <, > and / to the word characters in the preferences window to not have these deleted. This makes them part of the words, so it has other side-effects.
IF not - or as an immediate alternative - how would I create a regex & Macro that would delete all the space (including tabs, new lines, carriage returns etc ) up until the first < tag ??
Record a macro where you do cmd-f, set the find (regex) string to: “\A[ \t\n]+” and press return (to find it), press delete and stop recording.
The initial \A means “start of buffer” and ensures that the sequence of spaces, tabs, and newlines are only matched if they are to the immediate right of the caret.
On Nov 23, 2004, at 13:22, Allan Odgaard wrote:
Record a macro where you do cmd-f, set the find (regex) string to: “\A[ \t\n]+” and press return (to find it), press delete and stop recording.
The initial \A means “start of buffer” and ensures that the sequence of spaces, tabs, and newlines are only matched if they are to the immediate right of the caret.
THANK YOU !! : ) You've saved me a lot of grief there and what will amount to quite a bit of time!. That little Macro is so good, that it should (almost ?) be a standard Macro, or something like that.
Thank you yet again !
Kind regards,
Mats
On Nov 23, 2004, at 14:40, Mats Persson wrote:
Record a macro where you do cmd-f, set the find (regex) string to: “\A[ \t\n]+” and press return (to find it), press delete and stop recording. [...]
THANK YOU !! : ) You've saved me a lot of grief there and what will amount to quite a bit of time!. That little Macro is so good, that it should (almost ?) be a standard Macro, or something like that.
Probably I should add some default macros to strip white spaces and what some people refer to as gremlins (although I still haven't figured out exactly what characters are considered gremlins).
Regarding your macro, in case you want to make it a bit more generic, e.g. to bind it to alt-delete (and override the default word delete), you can also do “conditions” in regular expressions, for example if instead you use this pattern: \A([ \t\n])?(?(1)[ \t\n]*:[^ \t\n]*)
It will match 1-n white spaces, but if there are no white spaces, it will instead match 1-n non-white spaces (greedy).
To break it down: (foo)?
Will match 'foo' in capture register 1 if possible (the parenthesis makes it a capture, the question mark afterwards makes it a 0-1 repeat, i.e. optional match).
Then this (later in the same expression): (?(1)lhs:rhs)
Will match 'lhs' iff there is something in capture register 1 (i.e. that we matched 'foo'), otherwise it will match 'rhs'.
iff = if and only if lhs = left hand side rhs = right hand side