[VxE]
Joined: 07 Oct 2006 Posts: 1496
|
Posted: Sun Aug 24, 2008 10:22 pm Post subject: Manual block tabbing / detabbing |
|
|
This is a little something whipped up because I don't use a fancy editor that has built-in auto indenting and whatnot. Basically, what this script does is while the [`] button is held down, the [tab] and [esc] keys become hotkeys that add / remove indentation from the selected block of text. Doing so does not deselect the text, so you can spam it pretty easily. Releasing the [`] key will spit out a normal backtick otherwise.
It also converts alternate indentations (like the triple space from these forums) into tabs (configurable).
Tested in notepad. Comments welcome.
| Code: | ;<><><><><><><><><><><><><><><><><><><><><><><><>
;<><><><><><><><><><><><><><><><><><><><><><><><>
;<><>
;<><> Block Tabber/Detabber, by [VxE]
;<><>
;<><> Simply select a block of text
;<><> and use [`][tab] to tab it in
;<><> or [`][esc] to tab it back out
;<><>
;<><><><><><><><><><><><><><><><><><><><><><><><>
;<><><><><><><><><><><><><><><><><><><><><><><><>
#SingleInstance, Force
Indent := A_Tab ; your primary indentation character
Compatible := " " ; triple space (as per forum code blocks) or whatever
; other kind of indentation you want to integrate.
$`::
bktik = 0
Hotkey, $Tab, iTab, on
Hotkey, $Esc, iEsc, on
return
$` up::
Hotkey, $Tab, iTab, off
Hotkey, $Esc, iEsc, off
If !bktik
Send {blind}{``}
return
iTab:
bktik := BlockIndentChange( "`n", "`n" Indent, "`n" ,"`n" Compatible )
return
iEsc:
bktik := BlockIndentChange( "`n" Indent , "`n", "`n" Compatible, "`n")
return
BlockIndentChange( in1, out1, in2 = "", out2 = "")
{
clip := clipboardall
clipboard := ""
SendPlay, ^x
Clipwait, 9, 1
StringReplace, clipboard, clipboard, %in2%, %in1%, all
StringReplace, clipboard, clipboard, %out2%, %out1%, all
StringReplace, clipboard, clipboard, %in1%, %out1%, all
StringReplace, clipboard, clipboard, `r, `r, UseErrorLevel
total := Strlen(clipboard) - ErrorLevel
SendPlay, ^v+{Left %total%}
Clipboard := clip
return total
} |
_________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|