Copy a line of text without the LF

2006-08-08 Thread Meino Christian Cramer
Hi,

 I am using vim 7.0.42 on a Linux system.
 
 I want copy a complete line of text *without+ the final LF at the
 end, so it is possible to insert it elsewhere in the midth of text.

 With

Shift-V

 I get the line *with* the LF at the end -- so I can not use that.

 With

y/last character of the lineRET

 I get the line without the LF but the last character is also missing.

 With
 
y/$RET

 I get the line without the LF but the last character is missing again.


   :set selectionRET
 

 gives me the default (inclusive).


 What did I wrong ?

 Kind regards,
 mcc
 


Re: Copy a line of text without the LF

2006-08-08 Thread Jürgen Krämer

Hi,

Meino Christian Cramer schrieb:
 
  I am using vim 7.0.42 on a Linux system.
  
  I want copy a complete line of text *without+ the final LF at the
  end, so it is possible to insert it elsewhere in the midth of text.

[snip]

just use

  y$

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)



Re: Copy a line of text without the LF

2006-08-08 Thread Meino Christian Cramer
From: Jürgen Krämer [EMAIL PROTECTED]
Subject: Re: Copy a line of text without the LF
Date: Tue, 08 Aug 2006 10:56:24 +0200

 
 Hi,
 
 Meino Christian Cramer schrieb:
  
   I am using vim 7.0.42 on a Linux system.
   
   I want copy a complete line of text *without+ the final LF at the
   end, so it is possible to insert it elsewhere in the midth of text.
 
 [snip]
 
 just use
 
   y$
 
 Regards,
 Jürgen
 

Hi Jürgen,

 nice to now, that there is just another extra command... :)

 BUT: For what hopefully logical reason y/$ does not work? And more
 important: What is executed instead of one would extrapolate from
 knowing y/something other than $.

 Or -- exaggerated to the limit -- do I need another extra command to
 search/yank for example a m at line's end ???

 I miss some consistency at some place of the commands.

 (*NO* critism against YOU, Jürgen !!! EXCLAMATION MARKS!!!)

 Keep hacking!
 mcc

 
 -- 
 Sometimes I think the surest sign that intelligent life exists elsewhere
 in the universe is that none of it has tried to contact us. (Calvin)
 


Re: Copy a line of text without the LF

2006-08-08 Thread Meino Christian Cramer
From: Georg Dahn [EMAIL PROTECTED]
Subject: Re: Copy a line of text without the LF 
Date: Tue, 8 Aug 2006 10:05:45 +0100 (BST)

Hi Georg,

 thanks a lot for your reply! :)

 Good to know, that there are special commands to just copy a line
 completly without the LF.

 But why I do need a specialised command ?

 Why does 

 y/$

 (despite the settings of the selection option)

 not work ? Why do I have to leave / off and have to use 

 y$

 instead, as Jürgen said ???

 And  why does 

 yany other character

 does not work?

 Is this inconsistency needed?

 Keep hacking!
 mcc


 
 Hi!
 
 I would position the cursor on the line you want to copy and do
 
 0v$y
 
 0: move the cursor to the beginning of the line
 v: start visual mode
 $: move the cursor to the end of the line
 y: yank the selection
 
 Best wishes,
 Georg
 
 
 --- Meino Christian Cramer [EMAIL PROTECTED] wrote:
 
  Hi,
  
   I am using vim 7.0.42 on a Linux system.
   
   I want copy a complete line of text *without+ the final LF at the
   end, so it is possible to insert it elsewhere in the midth of text.
  
   With
  
  Shift-V
  
   I get the line *with* the LF at the end -- so I can not use that.
  
   With
  
  y/last character of the lineRET
  
   I get the line without the LF but the last character is also missing.
  
   With
   
  y/$RET
  
   I get the line without the LF but the last character is missing again.
  
  
 :set selectionRET
   
  
   gives me the default (inclusive).
  
  
   What did I wrong ?
  
   Kind regards,
   mcc
   
  
 
 
 
   
   
   
 ___ 
 All new Yahoo! Mail The new Interface is stunning in its simplicity and ease 
 of use. - PC Magazine 
 http://uk.docs.yahoo.com/nowyoucan.html
 


Re: Copy a line of text without the LF

2006-08-08 Thread Georg Dahn
Hi!

  But why I do need a specialised command ?

That's no specialised command, but the syntax of y. You type y and then a
motion. $ moves to the end of the line.

  Why does 
 
y/$

y/[pattern] moves to the first occurance of the pattern. The cursor is
positioned on the first character of the pattern, but this character is never
yanked (which is exactly what one expects normally).

 (despite the settings of the selection option)

The selection option is not relevant here, because you don't select anything
here.

 Why do I have to leave / off and have to use 
 
  y$

The syntax of y in Normal mode is y followed by a motion.

  And  why does 
 
  yany other character
 
  does not work?

If any other character is no motion, then this must not work.

  Is this inconsistency needed?

This is no inconsistency.

Just read:

:h motion.txt
:h copy-move

BTW, my suggestion has the advantage of using Visual mode. Sometimes you have
to type one character more, but this has the big advantage, that you can see,
what you are going to yank.

Best wishes,
Georg









___ 
All new Yahoo! Mail The new Interface is stunning in its simplicity and ease 
of use. - PC Magazine 
http://uk.docs.yahoo.com/nowyoucan.html


Re: Copy a line of text without the LF

2006-08-08 Thread Jürgen Krämer

Hi,

Meino Christian Cramer wrote:
 From: Jürgen Krämer [EMAIL PROTECTED]
 Subject: Re: Copy a line of text without the LF
 Date: Tue, 08 Aug 2006 10:56:24 +0200
 
  Meino Christian Cramer schrieb:
I am using vim 7.0.42 on a Linux system.
  
I want copy a complete line of text *without+ the final LF at the
end, so it is possible to insert it elsewhere in the midth of text.
  [snip]
 
  just use
 
y$

  nice to now, that there is just another extra command... :)

it's not a command, it's a combination of a command (yank) and a motion
(to the end of line).

  BUT: For what hopefully logical reason y/$ does not work?

/$ is a different motion than $ -- in general, / as a motion puts
the cursor before the start of the matched text. As $ is a zero-width
anchor and the cursor can't be positioned after the last character on a
line VIM uses the character before the match as start of matched text.
Exception: With :set virtualedit=all the cursor can be placed beyond
the end of line and your command would have worked as expected.

  And more
  important: What is executed instead of one would extrapolate from
  knowing y/something other than $.

Here again the cursor is put before the start of the matched text, e.g.,

  y/a

would yank up to but not including the next a. If you want to include
the a you will have to use offsets, i.e. in this special case

  y/a/e

or more generally

  y/amore text/s+1

would include the a. Have a look at :help search-offset for more
information on offsets in searches.

  Or -- exaggerated to the limit -- do I need another extra command to
  search/yank for example a m at line's end ???

  y/m/e

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)



Re: Copy a line of text without the LF

2006-08-08 Thread Charles E Campbell Jr

Jürgen Krämer wrote:


Meino Christian Cramer schrieb:
 


I am using vim 7.0.42 on a Linux system.

I want copy a complete line of text *without+ the final LF at the
end, so it is possible to insert it elsewhere in the midth of text.
   



[snip]

just use

 y$
 


For the entire line, try

 0y$

(this variant is immune to cursor placement in the line)

Regards,
Chip Campbell



Re: Copy a line of text without the LF

2006-08-08 Thread A.J.Mechelynck

Meino Christian Cramer wrote:

Hi,

 I am using vim 7.0.42 on a Linux system.
 
 I want copy a complete line of text *without+ the final LF at the

 end, so it is possible to insert it elsewhere in the midth of text.

 With

Shift-V

 I get the line *with* the LF at the end -- so I can not use that.

 With

y/last character of the lineRET

 I get the line without the LF but the last character is also missing.

 With
 
y/$RET


 I get the line without the LF but the last character is missing again.


   :set selectionRET
 


 gives me the default (inclusive).


 What did I wrong ?

 Kind regards,
 mcc
 





IIRC, in addition to all the suggestions made so far, to change a 
register from linewise (with NL or null at the end) to characterwise 
(without it) you can use (for instance with the default register):


:call setreg('', @, 'c')

or even

if setreg('', @, 'c')
echoerr 'Couldn''t set @ to characterwise'
endif

(the function return zero for success). Use setreg('x', @x, 'c') to use 
register x instead.



Best regards,
Tony.