The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Interchange 5.6.0 (Stable 5.6.x branch) iBot Software Releases - RSS News 0 05-22-2008 08:50 AM
Interchange 5.5.2 (Development branch) iBot Software Releases - RSS News 0 04-30-2008 04:50 AM
How to put the comments to 50 lines, using vi editor? artikulkarni UNIX for Dummies Questions & Answers 3 02-08-2008 04:57 AM
How to interchange the lines shankarao Shell Programming and Scripting 5 11-05-2006 02:28 PM
Reading lines within vi editor asriva26 Shell Programming and Scripting 2 08-30-2006 09:47 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-27-2008
DILEEP410 DILEEP410 is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 148
Question vi editor - interchange two lines

Hi,

I have a quick question regarding vi editor.Is it possible to interchange two lines in vi editor without using the possibilites of cut-paste,copy paste etc?

Your help is appreciated!

Regards
Dileep
  #2 (permalink)  
Old 08-28-2008
chihung chihung is offline
Registered User
  
 

Join Date: Jun 2008
Location: Singapore
Posts: 48
you need to 'map' certain key-stroke to do this

In vi, go into the command mode by keeping the following

:map , ddp

If you position your cursor in that line, by typing the "," (comma) key it will delete the current line and paste it below the current cursor. Basically it swaps the two lines.
  #3 (permalink)  
Old 08-31-2008
DILEEP410 DILEEP410 is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 148
Post

Quote:
Originally Posted by chihung View Post
you need to 'map' certain key-stroke to do this

In vi, go into the command mode by keeping the following

:map , ddp

If you position your cursor in that line, by typing the "," (comma) key it will delete the current line and paste it below the current cursor. Basically it swaps the two lines.
Thanks for your reply.But sorry i didn't get you properly.Can you put the logic in steps if you don't mind - for swapping two lines in vi editor.

Regards
Dileep Pattayath
  #4 (permalink)  
Old 09-01-2008
DILEEP410 DILEEP410 is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 148
Thumbs up

Quote:
Originally Posted by chihung View Post
you need to 'map' certain key-stroke to do this

In vi, go into the command mode by keeping the following

:map , ddp

If you position your cursor in that line, by typing the "," (comma) key it will delete the current line and paste it below the current cursor. Basically it swaps the two lines.
Now,I got it.I intrepret the statement you gave in a different way,but finally caught what you had suggested.It's seems great.

Thank you so much!

Regards
Dileep Pattayath
  #5 (permalink)  
Old 08-31-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
You can just type 'ddp'. dd = delete line, p = paste below. Chihung's method just defines a macro so you can do it with one keypress... which part do you need explaining?
Closed Thread

Bookmarks

Tags
sed delete line

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0