Discussion:
Capitalisation command or macro ?
Greg Edwards
2009-05-26 00:25:40 UTC
Permalink
Nedit comrades,
I have to capitalise a pile of text - massive list of book titles, eg
"night of the living dead" goes to 'Night Of The Living Dead". I was sure
nedit had this built in but just can't find it. Help appreciated.

Cheers,
Greg E
--
Greg Edwards
mob 0400 102 774
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
intertwingled
2009-05-26 01:08:51 UTC
Permalink
Greg:

I could write a Perl script that would do the trick in a minute.

Tony
Post by Greg Edwards
Nedit comrades,
I have to capitalise a pile of text - massive list of book titles, eg
"night of the living dead" goes to 'Night Of The Living Dead". I was sure
nedit had this built in but just can't find it. Help appreciated.
Cheers,
Greg E
--
I always have coffee when I watch radar!
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Matthijs van Aalten
2009-05-26 06:27:41 UTC
Permalink
Post by Greg Edwards
Nedit comrades,
I have to capitalise a pile of text - massive list of book titles, eg
"night of the living dead" goes to 'Night Of The Living Dead". I was sure
nedit had this built in but just can't find it. Help appreciated.
I'm not sure if you like a solution like this, but try:
- Menu => Search => Replace...
- String to find: <\l+>
(so left-pointy-bracket, backslash, lower-case letter L, plus-sign and right-pointy-bracket)
- Replace With: \u&
(so backslach, lower-case letter U, ampersand)
- Toggle-buttons: Regular Expression on, all others off
- Hit 'Replace all in: Window'...

This should capitalize all first letters of all words in your current editing window.

Good luck,
Matthijs
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Greg Edwards
2009-05-26 22:36:16 UTC
Permalink
Nedit Comrades,
Thanks for those responses. The one I used was Matthjis and his regex
search/replace below. I should have realised it would be easy there. Nedit
regex is certainly nice, seems to have the best of all the regex packages,
eg. non-greedy matching. I've experienced that before, you battle with grep,
grep -E, some Perl, to achive something, and then Nedit regex has it easy as
pie.

Cheers,
Greg E


On Tue, May 26, 2009 at 4:27 PM, Matthijs van Aalten <
Post by Matthijs van Aalten
Post by Greg Edwards
Nedit comrades,
I have to capitalise a pile of text - massive list of book titles, eg
"night of the living dead" goes to 'Night Of The Living Dead". I was sure
nedit had this built in but just can't find it. Help appreciated.
- Menu => Search => Replace...
- String to find: <\l+>
(so left-pointy-bracket, backslash, lower-case letter L, plus-sign and
right-pointy-bracket)
- Replace With: \u&
(so backslach, lower-case letter U, ampersand)
- Toggle-buttons: Regular Expression on, all others off
- Hit 'Replace all in: Window'...
This should capitalize all first letters of all words in your current editing window.
Good luck,
Matthijs
--
http://www.nedit.org/mailman/listinfo/discuss
--
Greg Edwards
mob 0400 102 774
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
AVKuznetsov
2009-05-26 06:39:15 UTC
Permalink
On Tue, 26 May 2009 10:25:40 +1000
Post by Greg Edwards
Nedit comrades,
I have to capitalise a pile of text - massive list of book titles, eg
"night of the living dead" goes to 'Night Of The Living Dead". I was sure
nedit had this built in but just can't find it. Help appreciated.
Cheers,
Greg E
Hi Greg!

Try following macro.

define capitalize_region {
if( $selection_start != -1 ) {
start = $selection_start
end = $selection_end
} else {
start = 0
end = $text_length
}
string = get_range(start, end)
for(position=0; 1; position = $search_end) {
position = search_string(string, "(?<=\\L|^)\\l+", position, "regex")
if(position < 0)
break
char = toupper(substring(string, position, position +1))
string = replace_substring(string ,position, position +1, char)
}
replace_range(start, end, string)
}

You can tune the macro and replace \\L to \\s to capitalize
only words separated by spaces.

Cheers,
Alexey Kuznetsov
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Loading...