On 09/11/08 04:52, Matt Wozniski wrote:
> On Sat, Nov 8, 2008 at 7:56 PM, Gary Johnson wrote:
>> On 2008-11-08, Hari wrote:
>>> I'm trying this from a script:
>>>
>>> :let a='sometext'
>>> :put =a
>>>
>>> The behavior is that a newline is always created and 'sometext' added there.
>>> Is there some way to just put text on the current line without automatically
>>> having a newline inserted? I could use setline, but that is sort of
>>> inappropriate for my usage. I just wish to dump text and add newlines myself
>>> if needed.
>> How about either of these?
>>
>> 1.
>> :let a='sometext'
>> :exe "normal a\<C-R>=a\<CR>"
>>
>> 2.
>> :let @a='sometext'
>> :normal "ap
>
> :let @@='sometext'
> :normal p
>
> That would be identical to 2) above, but with the advantage of
> clobbering the unnamed register instead of one of the unnamed
> registers... Sure, it's better to not clobber either one without
> saving and restoring, but at least users tend not to expect the things
> in the unnamed register to stick around for long, but often want the
> lettered registers saved for a long time.
>
> ~Matt
Yes, unlike normal-mode commands, all ex-commands (not only :put but
also :yank, :delete, :print, :substitute, :read, :write, etc.) always
act linewise. This may be quite useful, e.g. I use the following
mappings to insert the clipboard contents at top or bottom of the
current editfile:
:map <F4> :$put +<CR>
:map <S-F4> :0put +<CR>
Whenever you want to paste linewise what may have been copied or cut
characterwise, ":put" is your friend.
Best regards,
Tony.
--
GALAHAD: Camelot ...
LAUNCELOT: Camelot ...
GAWAIN: It's only a model.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---