If you don't know how to do it with one command (and neither do I), we can
always create a mapping to do it with one key:
:map <F3> :exe ".w! myfile" | .d<CR>
The ":execute" wrapper around the ":write" command is necessary because
otherwise the bar would be seen as an argument to ":w", see ":help :|".
Best regards,
Tony.
--
"Ah, you know the type. They like to blame it all on the Jews or the
Blacks, 'cause if they couldn't, they'd have to wake up to the fact
that life's one big, scary, glorious, complex and ultimately
unfathomable crapshoot -- and the only reason THEY can't seem to keep
up is they're a bunch of misfits and losers."
-- A analysis of Neo-Nazis, from "The Badger" comic
>Roy Fulbright wrote:
>
>
>>I know that ":.w myfile" will write the current line to a new file, but
>>what I want is to write the current line to a new file AND cut it from
>>the current file at the same time. I have searched help and the Vim wiki
>>but cannot find any single command to do this. Does anyone know how to
>>do this with one command? Thanks in advance.
>>
>>
>
>If you don't know how to do it with one command (and neither do I), we can
>always create a mapping to do it with one key:
>
> :map <F3> :exe ".w! myfile" | .d<CR>
>
>The ":execute" wrapper around the ":write" command is necessary because
>otherwise the bar would be seen as an argument to ":w", see ":help :|".
>
>
Or you could use <bar>, as in
:map <f3> w! myfile<bar> .d<cr>
Regards,
Chip Campbell
You should use <Bar> because ":map" doesn't see | as part of its arguments,
but you should also wrap the ":write" statement because it does see | (which
is what ":map" would transform <Bar> into) as part of _its_ arguments. So:
:map <F3> :exe ".w! myfile" <Bar> .d<CR>
Best regards,
Tony.
--
People will buy anything that's one to a customer.
!!cat > newfile
which will overwrite newfile or
!!cat >> newfile
which will append the line to newfile.
HTH,
Gary
if it isn't actually a new file...
> !!cat >> newfile
>
> which will append the line to newfile.
if it isn't actually a new file...
Grins,
Ben.
Send instant messages to your online friends http://au.messenger.yahoo.com