Tapatalk

Capitalize first letter of each line

Capitalize first letter of each line

23
Basic UserBasic User
23

    Jun 04, 2008#1

    Hi All,

    I frequently take notes without capitalizing the first letter of each line. I'd like to do that with an UltraEdit script. How would I do so?

    Thanks,

    Rob

    119
    Power UserPower User
    119

      Jun 05, 2008#2

      You don't need a script. A search and replace will do it just as well (and faster).
      Find What: ^(\s*\w)
      Replace With: \U$1

      Be sure to check Regular Expressions and select Perl as the regex engine.

      Since it sounds like you'll want to use it regularly you can run it from a macro:

      Code: Select all

      InsertMode
      ColumnModeOff
      HexOff
      PerlReOn
      Find RegExp "^(\s*\w)"
      Replace All "\U$1"

      23
      Basic UserBasic User
      23

        Capitalizing the first letter of each line

        Jun 10, 2008#3

        Hi all,

        I've got a script that I modified from a Macro to capitalize the first letter of each line. It doesn't seem to do -- anything.

        Any ideas?

        Code: Select all

            // Is any file currently open?
            
               UltraEdit.ueReOn();
               UltraEdit.activeDocument.hexOff();
               UltraEdit.activeDocument.bottom();
               // Is the last line of the file terminated with a line ending?
               if (UltraEdit.activeDocument.isColNumGt(1)) {
                  // No, insert missing line ending (DOS, UNIX or MAC).
                  UltraEdit.insertMode();
                  if (typeof(UltraEdit.columnModeOff) == "function") UltraEdit.columnModeOff();
                  else if (typeof(UltraEdit.activeDocument.columnModeOff) == "function") UltraEdit.activeDocument.columnModeOff();
                  UltraEdit.activeDocument.insertLine();
                  // If auto indent is enabled and last line starts with white-spaces,
                  // delete the automatically inserted white-spaces in the new last line.
                  if (UltraEdit.activeDocument.isColNumGt(1)) {
                     UltraEdit.activeDocument.deleteToStartOfLine();
                  }
               }
               UltraEdit.activeDocument.top();
               
               
               UltraEdit.activeDocument.findReplace.mode=0;
               UltraEdit.activeDocument.findReplace.searchDown=true;
               UltraEdit.activeDocument.findReplace.matchCase=false;
               UltraEdit.activeDocument.findReplace.matchWord=false;
               UltraEdit.activeDocument.findReplace.regExp=true;
               UltraEdit.activeDocument.findReplace.replaceAll=true;
               
               
               UltraEdit.activeDocument.findReplace.replace("^(\s*\w)","\U$1");
        

        262
        MasterMaster
        262

          Re: Capitalizing the first letter of each line

          Jun 10, 2008#4

          Business as usual: Backslashes must be escaped in strings in javascript:

          UltraEdit.activeDocument.findReplace.replace("^(\\s*\\w)","\\U$1");

          and you are using Perl regexp, so add UltraEdit.perlReOn();

          23
          Basic UserBasic User
          23

            Re: Capitalizing the first letter of each line

            Jun 10, 2008#5

            That was it. Thank you very much! Has anyone given a thought to a wiki for UltraEdit scripts? I'd be happy to help putting it together.