Re: Capitalisation command or macro ?
AVKuznetsov <kuzn-Z+4OxV1pPnQgONJHhpZ/[email protected]>
| Newsgroups | gmane.editors.nedit.user |
|---|---|
| Organization | MEPhI |
| Message-ID | <[email protected]> |
On Tue, 26 May 2009 10:25:40 +1000 Greg Edwards <[email protected]> wrote: > 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 - [email protected] http://www.nedit.org/mailman/listinfo/discuss