Delete everything after a number of characters in string in Notepad++

23
2014-04
  • David

    The following is an example of characters per line in Notepad ++. I need to limit the characters per line to 14 characters.

    11111111111111111111
    222222222222222222222222222
    33333333333333333333333

    I need it to look like the following:

    11111111111111
    22222222222222
    33333333333333

    How can I can limit the number of characters to 14 characters per line in Notepad++

  • Answers
  • tumchaaditya

    Do a Regex replace.
    Replace ^(.{14}).*$ with \1. Keep the . matches newline option unchecked.

  • chaput

    In notepad++ you can use the find and replace function like this : enter image description here


  • Related Question

    How would I delete the first 27 characters from every line Notepad++?
  • Adam543i

    I have a log file and I need to remove the first 27 characters off every line. You would have a line like this:

    2011-09-25 01:25:29 [INFO] <Exazoro> wazup
    

    But it needs to be like this:

    <Exazoro> wazup
    

  • Related Answers
  • Daniel Beck

    Use regular expression search, search for ^........................... and replace with (empty string).

    enter image description here

    Unfortunately, Notepad++ does not support repetition counts like ^.{27} — the SciTE regexp documentation applies here as well.


    Alternatively, use rectangular multi-line selection (press Alt while selecting) to select these first 27 characters in every line, then press Delete or Backspace.

    enter image description here


    Using Unix tools (e.g. Cygwin, UnxUtils) you can use cut -c28- or sed -E "s|^.{27}||" instead. At least, these are the Linux command line calls you'd use...

  • Thyag

    Below is the macro way. This is more intuitive for non-technical people:

    1) Place cursor on the first line (any cursor position)

    2) Click : Macro -> Start Recording

    3) Do the following key press activities:

    * Press the Home key  
    * Press Delete key 27 times (till you reach the intended character)
    * Press down arrow button. 
    

    4) Click : Macro -> Stop Recording

    5) Click : Run Macro Multiple times -> select Run until the end of file -> click Run.