paste & formatting

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

paste & formatting

William Pursell

Yesterday, a bizarre thing happened that I have not
been able to replicate, and I'm hoping someone can
tell me a) exactly what I might have done, and b) how
to avoid it in the future.

I had a mostly empty function definition:

void
foo(void)
{
    return;
}

I selected a bunch of code from a fully written function,
by doing 'y%' with the cursor on the open brace of the function,
and then went into foo and pasted with 'p'.  The text pasted
fine, but all of the functions in the file below foo were
re-formatted so that the return type was indented:

       type
baz (void)
{....

Why did the re-format happen?  I probably had paste set, but
can't think of anything else that was different than my normal
settings, and as I said I can't replicate the behavior.

Any help appreciated.
Reply | Threaded
Open this post in threaded view
|

:sh doesn't open shell window

Kev-13
I am using version 7 on Mac OS X.  When I open a shell with :sh, Vim  
only runs a single command line at the bottom of the screen. In  
previous versions and on my Windows box the :sh command opens a new  
shell window.  In addition, the 'clear' command doesn't clear and  
redraw the screen.

How can Vim be configured to open a new window for a shell?
Can I force a clear when in shell?

TIA,
Kevin

Reply | Threaded
Open this post in threaded view
|

Re: :sh doesn't open shell window

A.J.Mechelynck
stri ker wrote:

> I am using version 7 on Mac OS X.  When I open a shell with :sh, Vim
> only runs a single command line at the bottom of the screen. In previous
> versions and on my Windows box the :sh command opens a new shell
> window.  In addition, the 'clear' command doesn't clear and redraw the
> screen.
>
> How can Vim be configured to open a new window for a shell?
> Can I force a clear when in shell?
>
> TIA,
> Kevin
>
>
>

It isn't possible to run a shell inside a Vim window, and it never was,
see ":help shell-window".
While :sh runs, the command-line expands as necessary, up to the whole
Vim screen (and your buffer windows aren't accessible anyway, Vim stays
in command-line mode until you exit the shell). That command-line
behaves as a "dumb teletype" terminal, as if your Vim screen had been
turned into a sheet of paper with a teletypewriter printing carriage
moving across it but never upwards. (When Unix was invented such
teletypewriters were the only existing consoles.) On such a terminal you
cannot clear the screen; at bast you can only tear away the paper.
To open a shell in a separate window, I can for instance click the
"Konsole" icon in the quick-launch part of my KDE taskbar. I don't know
the Mac but some similar possibility must exist.


Best regards,
Tony.
Reply | Threaded
Open this post in threaded view
|

Re: :sh doesn't open shell window

A.J.Mechelynck
Chris Sutcliffe wrote:

>> It isn't possible to run a shell inside a Vim window, and it never was,
>> see ":help shell-window".
>
> I think what Kevin was referring to was that :sh used to spawn a
> separate shell window for him, such as vim on Windows spawning
> cmd.exe.  I believe this is controlled by the 'shell' variable in your
> .vimrc.
>
> Chris
>

The 'shell' variable holds the name of the shell. To spawn a separate
shell window on Linux (I don't know Mac) I guess you should actually run
konsole or xterm, not the shell. (I've tried ":!bash &" in Vim but I
don't see any shell window; OTOH ":!bash" or ":shell" give the same
result: a shell on the Vim command-line, pushing buffer windows away
until "exit".)


Best regards,
Tony.
Reply | Threaded
Open this post in threaded view
|

Re: paste & formatting

iler.ml
In reply to this post by William Pursell
On 6/28/06, Bill Pursell <[hidden email]> wrote:

>
> Yesterday, a bizarre thing happened that I have not
> been able to replicate, and I'm hoping someone can
> tell me a) exactly what I might have done, and b) how
> to avoid it in the future.
>
> I had a mostly empty function definition:
>
> void
> foo(void)
> {
>     return;
> }
>
> I selected a bunch of code from a fully written function,
> by doing 'y%' with the cursor on the open brace of the function,
> and then went into foo and pasted with 'p'.  The text pasted
> fine, but all of the functions in the file below foo were
> re-formatted so that the return type was indented:
>
>        type
> baz (void)
> {....
>
> Why did the re-format happen?  I probably had paste set, but
> can't think of anything else that was different than my normal
> settings, and as I said I can't replicate the behavior.

Irreproduceble things tend to be unexplainable.

Yakov