LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-02-2007, 08:39 AM   #1
[KIA]aze
Member
 
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?

ex:
input:
hgfhdsfgjv expr sfdsjhfk expr hfjshkf

output:
hgfhdsfgjv
sfdsjhfk
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, 12:59 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

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

Rep: Reputation: 75
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, 01:48 PM   #4
[KIA]aze
Member
 
Registered: Jun 2006
Distribution: Debian, Ubuntu, Windows XP
Posts: 146

Original Poster
Rep: Reputation: 16
Thanks.
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:
->replace
-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.

P.S:
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 01:54 PM.
 
Old 04-19-2009, 07:02 PM   #5
linuxquestionsorg42
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:

Quote:
Tip
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.
 
  


Reply


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 08:13 PM
C ++ I/O: Replace a line FreeDoughnut Programming 7 10-31-2006 09:21 PM
Kate - Regular Expression Replace and Other Features? apachedude Linux - Software 0 01-04-2005 02:49 PM
Kate Is Not Working, Kate editor is not starting in Redhat 9 apur Linux - General 4 05-11-2004 10:52 AM
sed: replace one line with >one line bbeers Programming 3 11-19-2002 06:27 PM


All times are GMT -5. The time now is 05:45 PM.

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