Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-02-2007, 07:39 AM   #1
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Rep: Reputation: 16
Kate: Replace with a new line

How can I replace an expression with a new line?

I know I can add expressions at the beginning and end of lines by using "^" and "$" in the replace dialog of Kate.

But how can I add new line characters by replacing expressions with a new line?

hgfhdsfgjv expr sfdsjhfk expr hfjshkf


I would like to do that with Kate, but a command-line solution like awk or sed is also ok.
It's just that I don't have time right know to learn more tricks with awk, sed&co. ^^'
Old 05-02-2007, 11:59 AM   #2
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 76
sed -e 's/expr /\n/g'
Old 05-02-2007, 12:01 PM   #3
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 76
Alternate ending:
  1. Uninstall Kate
  2. Install vi
  3. Open file in vi/ex
  4. Type :%s/expr /\n/g
  5. Type :wq
Old 05-02-2007, 12:48 PM   #4
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Original Poster
Rep: Reputation: 16
Yes, I know about vim and have already started learning it, but it's really much less user-friendly than kate.
I already like the {} matching feature with %.

But for the command feature, you can also do that in kate with the inbuilt terminal.

I also found out how to replace expressions with \n in emacs in the meanwhile:
-enter expression
-enter ctrl+q,ctrl+j by pressing those keys
-press enter
-press "!" to replace all lines

Command line is quicker of course, as always.

The console editor I use the most is nano...
It's the first I learned to use on UNIX.

Last edited by [KIA]aze; 05-02-2007 at 12:54 PM.
Old 04-19-2009, 06:02 PM   #5
LQ Newbie
Registered: Sep 2006
Posts: 9

Rep: Reputation: 0
Checkout Kate's command line - F7

This response may be long overdue, but I found the answer to a similar question, and perhaps someone else can benefit in the future.

Use Kate's command line: View -> Switch to command line (F7).

And then you can do sed-like command: "%s/expr /\n/g".

I found this answer in Kate's Handbook. The last line in the section, "The Find Text and Replace Text Dialogs", said:

You can do find, replace and ifind (incremental search) from the command line.
I clicked on the link, "command line", in the manual and found lots of good information ;-)

Hope that helps.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
vim search and replace only one line hakmed Programming 5 11-07-2006 07:13 PM
C ++ I/O: Replace a line FreeDoughnut Programming 7 10-31-2006 08:21 PM
Kate - Regular Expression Replace and Other Features? apachedude Linux - Software 0 01-04-2005 01:49 PM
Kate Is Not Working, Kate editor is not starting in Redhat 9 apur Linux - General 4 05-11-2004 09:52 AM
sed: replace one line with >one line bbeers Programming 3 11-19-2002 05:27 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration