EmEditor (text editor) Forum Index
   Macro Samples
     Macro: Select whole paragraph
Register To Post

Flat Previous Topic | Next Topic
Poster Thread
Stefan
Posted on: 5/2/2012 12:12 pm
Home away from home
Joined: 7/14/2008
From: Germany, EU
Posts: 263
Macro: Select whole paragraph
I miss this feature in the EmEditor core:


#language = "VBScript"
' Select whole paragraph macro.
' An paragraph is an block of text delimited by two empty lines.
' How to:
' 1. Have the cursor inside an paragraph
' 2. execute this macro.

'Find next empty line UP:
'''''''''''''''''''''''''
Do While TRUE
		'//Returns the line number of the cursor position.
		yPos = document.selection.GetActivePointY( eePosLogical )
		yLine = yPos
		'//Retrieves the text on the specified line.
		str = document.GetLine( yLine ) 	'[, flag ] )
                '//Trim removes spaces on both sides of a string.
		str = Trim(str)
		If Len(str) > 0 Then
			'//Moves the cursor up a specified number of lines.
			document.selection.LineUp 	'[ bExtend [, nCount ] ]
		Else
			Exit Do
		End If
Loop

'Start the selection:
'''''''''''''''''''''
		document.selection.LineDown
		'//Moves the cursor to the start of the line.
		document.selection.StartOfLine 		'[ bExtend [, nFlags ] ]
		'//Selects a line at the cursor.
		document.selection.SelectLine

'Find next empty line DOWN:
'''''''''''''''''''''''''''
Do While TRUE
		'//Returns the line number of the cursor position.
		yPos = document.selection.GetActivePointY( eePosLogical )
		yLine = yPos
		'//Retrieves the text on the specified line.
		str = document.GetLine( yLine ) 	'[, flag ] )
		str = Trim(str)
		If Len(str) > 0 Then
			'//Moves the cursor down a specified number of lines.
			document.selection.LineDown True  '[ bExtend [, nCount ] ]
		Else
			'//Select the trailing empty line too:
			'document.selection.LineDown True 
			Exit Do
		End If
Loop
Flat Previous Topic | Next Topic


Subject Poster Date
 » Macro: Select whole paragraph Stefan 5/2/2012 12:12 pm
     Re: Macro: Select whole paragraph Stefan 5/3/2012 12:57 pm
       Re: Macro: Select whole paragraph webern 5/3/2012 11:33 pm
         Re: Macro: Select whole paragraph Stefan 5/4/2012 6:16 am
           Re: Macro: Select whole paragraph webern 5/4/2012 1:33 pm
             Re: Macro: Select whole paragraph Stefan 5/7/2012 3:42 am
               Re: Macro: Select whole paragraph Stefan 7/10/2012 6:18 am
                 Re: Macro: Select whole paragraph netsking 1/28/2013 11:30 am

Register To Post
 
English čeština Deutsch español français italiano 日本語 한국어 Русский 简体中文 繁體中文