Select a specific number of characters

English main discussion
Post Reply
  • Author
  • Message
Offline
Posts: 29
Joined: Tue Jun 30, 2020 11:33 am

Select a specific number of characters

Post by random6_2020 »

Is there a way, maybe a plugin, to select a certain number of bytes/characters forward or backward from the cursor, preferably stopping at word boundaries :?:

Offline
Posts: 43
Joined: Sat Jul 05, 2008 11:30 am
Location: Odesa, Ukraine

Re: Select a specific number of characters

Post by ewild »

random6_2020

As an example:
At first, the script will select 12 chars before the cursor position and then 12 chars after it.

Code: Select all

// https://akelpad.sourceforge.net/forum/viewtopic.php?p=36773#p36773
// selectNcharsRelativetoCursor.js
// select a specified number of chars relative to cursor
// 2025-04-01 ewild

// select from the cursor position backward/up/toward the beginning
AkelPad.TextFind(0,".{12}",0x001C0000);

WScript.Echo('hit ok to continue');

// select from the cursor position forward/down/toward the end
AkelPad.TextFind(0,".{12}",0x000C0001); 

// Scripts-Eng.txt
// AkelPad.TextFind
// 0x00040000 dot symbol '.' in regular expressions specifies any character except new line
// 0x00080000 search with regular expressions
// 0x00100000 find up
// 0x001C0000 = sum of above
Basically, all you need is to make a regex that fits your needs.
As you can see, in the given example, I used ".{12}" regex query (so, any 12 chars) within AkelPad.TextFind() (backward and then forward).
Post Reply