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

60

18

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

Mythrillic

Posted 2011-09-25T10:15:38.583

Reputation: 1 959

you could use some varient of the unix cut command from unxutils or busybox to do that much more easily - does it have to be notepad++? – Journeyman Geek – 2011-09-25T10:21:51.223

@JourneymanGeek it dosn't have to be notepad++ its just waht i mainly use and it has macro and plugin support so i guessed there might be something to do that. – Mythrillic – 2011-09-25T10:24:22.860

Answers

78

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...

Daniel Beck

Posted 2011-09-25T10:15:38.583

Reputation: 98 421

1wow! thanks for that rectangular selection tip... I wasn't even aware that something like that exists... – Fr0zenFyr – 2014-09-03T07:49:34.547

Alt + Shift + PgDwn first, and then Alt + Shift + Right 27 characters worked for me. The regex answers won't work correctly if the strings are longer than 54 characters. – Lou Morda – 2015-06-10T18:14:17.193

+1, you just saved my 2 hours. The rectangular selection was a great idea too – asprin – 2015-10-06T05:46:34.910

+1 for the Cygwin option, the NPP stucked since im working on huge files and the Cygwin won here – yossico – 2016-07-21T11:43:55.273

!!! rectangular multi-line selection !!! easyyyyyyy.. Great – Legends – 2016-07-28T02:47:39.783

25Alt + Shift + right to select the 27 characters in the first row, then Pg Dn whilst still holding Alt + Shift should do it – icc97 – 2011-09-25T11:25:41.010

1For the regex, Notepad++ doesn't follow all the standard regex rules, so I'm not surprised that you couldn't get it to work. And since it looks like the first 27 characters are a date, time, and error level, a more informative regex might be possible, like ^[0-9\-]+ [0-9:]+ \[[A-Z]+\] – MBraedley – 2011-09-25T12:46:52.680

4Loving the Alt for rectangular selection!! – Gromer – 2012-09-14T21:27:26.337

Alt selection simple and easy. Thanks Daniel Beck. – Uday Kiran Thummalapalli – 2013-04-09T17:49:43.260

19

In newer versions of Notepad++, you can use repetition counts. Just replace ^.{1,27} with empty string.

Schism

Posted 2011-09-25T10:15:38.583

Reputation: 461

7Of course, if it's guaranteed to be exactly 27 characters, just use ^.{27}. – Schism – 2014-06-02T17:16:53.453

5

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.

Thyag

Posted 2011-09-25T10:15:38.583

Reputation: 151

4

UPD: Now Notepad++ does support following repetition: ^.{27} But now you notepad++ will repeat remove characters until more than 27, to avoid this you can use the following expression:

  • Find what: ^.{27}(.*)$
  • Replace with: $1

Yurii

Posted 2011-09-25T10:15:38.583

Reputation: 41

this works perfectly! – Rudy – 2019-04-29T05:39:47.303

2

a small improvement to Daniel Beck answer:
Use regular expression search, search for:

^...........................(.*.\r\n) 

and replace with:

\1

Yakir Manor

Posted 2011-09-25T10:15:38.583

Reputation: 121

0

maybe just select text with ALT + Mouse left button

majkelml

Posted 2011-09-25T10:15:38.583

Reputation: 1

Can you elaborate on this a little more? – Toto – 2019-10-18T15:27:26.920

0

ALT + SHIFT + Mouse selection (only ALT is not working)

Point at the beginning of the file, go to the end hold ALT+SHIFT and point on the position u want to...

user1105565

Posted 2011-09-25T10:15:38.583

Reputation: 1