3

I am trying to add (' to the front of every line.

I tried

Find what: ^
Replace with: ('

and bracket did not show up.

How can I add it to the beginning of each line?

3 Answers 3

15

I am trying to add (' to the front of every line

( is a special character, you need to escape it with \

  • Menu "Search" > "Replace" (or Ctrl + H)

  • Set "Find what" to ^

  • Set "Replace with" to \('

  • Enable "Regular expression"

  • Click "Replace All"

    Image

Before:

Lorem ipsum dolor sit amet adipiscing ultricies varius egestas.
Lorem ipsum dolor sit amet adipiscing ultricies varius egestas.
Lorem ipsum dolor sit amet adipiscing ultricies varius egestas.
Lorem ipsum dolor sit amet adipiscing ultricies varius egestas.

After:

('Lorem ipsum dolor sit amet adipiscing ultricies varius egestas.
('Lorem ipsum dolor sit amet adipiscing ultricies varius egestas.
('Lorem ipsum dolor sit amet adipiscing ultricies varius egestas.
('Lorem ipsum dolor sit amet adipiscing ultricies varius egestas.

Further reading

3
  • 3
    Regular expressions: the cause of and solution to all of programming's problems. +1
    – MonkeyZeus
    Jan 8, 2016 at 20:35
  • @MonkeyZeus Agreed. I get lots of rep answering Notepad++ reg exp questions ;)
    – DavidPostill
    Jan 8, 2016 at 20:36
  • Thank you very much, along with another post on similar, I was able to do what I needed. Apr 26, 2022 at 17:57
4

An alternative to using Find/Replace could be to use a Macro:

  1. Record a macro of you hitting Home twice, inserting your characters and then moving your cursor down to the next line (with your down arrow key).
  2. Run that macro "until the end of file".

enter image description here

Example of how to use macros in Notepad++:

enter image description here

Animation source/more info

2
  • Hmm. Adding (' to the start of every line is not the same as joining all the lines up and separating them with ',', with no ( anywhere after you are finished. Are you answering some other question?
    – DavidPostill
    Jan 8, 2016 at 16:26
  • @DavidPostill The "example usage" animation is to show how to use macros in Notepad++, not how to solve this exact issue (that's what the rest of the answer is for). I made a couple changes to help clarify. ;) Jan 8, 2016 at 16:35
0

Just informational (RegEx replace is the best in this situation)...

There is Column Mode Editing in Notepad++, so you can:

  • Go to file begin Ctrl+Home.
  • Mark to file end Ctrl+Shift+End.
  • Mark to line begin in column modeShift+Alt+Home.
  • Type ('.

Column Mode is more useful with Column Editor when you are inserting numbers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .