LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-16-2008, 07:42 PM   #1
leocharre
LQ Newbie
 
Registered: Mar 2008
Location: Maryland
Distribution: 2.6.23.15-137.fc8
Posts: 7

Rep: Reputation: 0
how to put contents of register to line x using vim exec mode


I would like to be able to (p)ut to a line number without placing the caret in the place.
I want to be able to enter visual mode, highlight something, and then (p)ut it to line 23- for example.

How would I go about using :EXEC mode to (p)ut the contents of the register into line x?

i tried :45p .. ?
 
Old 03-17-2008, 12:53 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 77
Try this:
  1. Highlight lines in visual mode
  2. Type
    Code:
    :'<,'>m45
    Note that the '<,'> might automatically be entered for you when you have already highlighted text.
 
Old 03-19-2008, 04:24 PM   #3
leocharre
LQ Newbie
 
Registered: Mar 2008
Location: Maryland
Distribution: 2.6.23.15-137.fc8
Posts: 7

Original Poster
Rep: Reputation: 0
figured out a solution

Ok, I figured it out!
I wanted to do what you mention, but also maybe not even use visual mode at all.

Imagine I want to yank(copy) lines 123 through 140 and put(paste) them starting at line 14

Copy the lines..

Code:
:123,140y
Paste the lines starting at line 14

Code:
:14put
I had tried :14p but you need to say 'put'.

Similarly this works with what you haev in the register.
So if you want to move line 10 to line 200

Code:
:10d

:199put
What I want to find out now, is how to do this in one command (without hitting enter), yank and put..

---

Thanks osor, that's not what I had in mind, but it's very interesting.. spooky even..

Last edited by leocharre; 03-19-2008 at 04:26 PM.
 
Old 03-19-2008, 08:03 PM   #4
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 77
Well, the example I gave used the special Vim marks ‘'<’ and ‘'>’ for specifying addresses. You could just as well have done:
Code:
:123,140m14
Notice that the above command is the equivalent of “cut and paste” whereas the following command does “copy and paste”
Code:
:123,140t14
Also, if you don’t like the above solutions, you can always use multiple ex commands on a single line if they are separated by a ‘|’ character. E.g.,
Code:
:123,140y|14pu
 
  


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
file contents to command line args hawkmauk Linux - General 3 11-21-2006 02:27 PM
How to register a program for command line?? wepakis Linux - Software 8 11-13-2004 03:07 AM
VIM Setup- No 'insert' mode uveraser Linux - Software 1 05-25-2004 11:44 AM
vim: coding mode and doc writing mode? miknight Linux - Software 2 03-07-2004 09:51 PM
insert mode in vim usr Linux - Software 1 01-18-2004 02:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:26 AM.

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
Open Source Consulting | Domain Registration