wiki:ChangeHeadingLevel

Scripts which will increase/decrease the level of the headings in the selection.

Usage:

Ctrl-2 will increase the level of the headings in the selection,

Ctrl-3 will decrease.

Installing this: See here: HowToInstallGlobalScripts

<% 2: 
import re

beginSel=editor.GetSelectionStart()
endSel=editor.GetSelectionEnd()

text = editor.GetSelectedText()

p = re.compile(u"^\\+(\\++?)",
        re.DOTALL | re.UNICODE | re.MULTILINE)
newtext, replacements = p.subn(r'\g<1>', text)
editor.ReplaceSelection(newtext)

editor.SetSelectionStart(beginSel)
editor.SetSelectionEnd(endSel-replacements)
%>

<% 3: 
import re

beginSel=editor.GetSelectionStart()
endSel=editor.GetSelectionEnd()

text = editor.GetSelectedText()
p = re.compile(u"^(\\++?)",
        re.DOTALL | re.UNICODE | re.MULTILINE)
newtext, replacements = p.subn(r'\g<1>+', text)
editor.ReplaceSelection(newtext)

editor.SetSelectionStart(beginSel)
editor.SetSelectionEnd(endSel+replacements)
%>
Last modified 8 years ago Last modified on May 9, 2009 10:14:06 AM