Run commands at Vi Startup and exiting
I work on a PuTTY terminal on Windows connecting HP-UX11i. When I
invoke vi or vim and maximum the PuTTY with vi, the editor can't
detect the change of the window size. often I execute resize after
maximum the window and before start vi, and execute resize after exit
vi and restore the window size.
Can I put the resize command in a `vi' script and run the script
automatically every time at the startup and exit of vi?
Re: Run commands at Vi Startup and exiting
In <1177550791.402329.247190@n15g2000prd.googlegroups.com> "lovecreatesbea...@gmail.com" <lovecreatesbeauty@gmail.com> writes:
[color=blue]
> Can I put the resize command in a `vi' script and run the script
> automatically every time at the startup and exit of vi?[/color]
I don't know of any way to make vi execute a script automatically upon
startup.
You could make a script like this:
resize
vi $*
resize
And just run the script instead of running vi directly. Or make it
a shell alias instead, if you like that better.
--
John Gordon A is for Amy, who fell down the stairs
[email]gordon@panix.com[/email] B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Re: Run commands at Vi Startup and exiting
On 2007-04-26, lovecreatesbea...@gmail.com <lovecreatesbeauty@gmail.com> wrote:[color=blue]
> I work on a PuTTY terminal on Windows connecting HP-UX11i. When I
> invoke vi or vim and maximum the PuTTY with vi, the editor can't
> detect the change of the window size. often I execute resize after
> maximum the window and before start vi, and execute resize after exit
> vi and restore the window size.
>
> Can I put the resize command in a `vi' script and run the script
> automatically every time at the startup and exit of vi?[/color]
Try connecting via ssh instead of telnet or rlogin. The ssh protocol
has the ability to advise of changes in terminal size dynamically:
telnet doesn't. I'm currently typing this from PuTTY connected to
a NetBSD box and new vi. Any change in terminal size causes a
SIGWINCH which vi handles automatically.
SIGWINCH is one of those things that sometimes doesn't work - it
depends on several different elements all supporting it, but on
reasonably modern systems you shouldn't have any problems. If you
do ask back here and someone may be able to help.
--
Andrew Smallshaw
[email]andrews@sdf.lonestar.org[/email]
Re: Run commands at Vi Startup and exiting
Andrew Smallshaw <andrews@sdf.lonestar.org> wrote:
[color=blue]
> Try connecting via ssh instead of telnet or rlogin. The ssh protocol
> has the ability to advise of changes in terminal size dynamically:
> telnet doesn't. I'm currently typing this from PuTTY connected to[/color]
any reasonably recent telnet implements NAWS
[url]http://www.faqs.org/rfcs/rfc1073.html[/url]
(noting that some applications on various platforms are maintained in
a bug-for-bug compatibility mode).
--
Thomas E. Dickey
[url]http://invisible-island.net[/url]
[url]ftp://invisible-island.net[/url]
Re: Run commands at Vi Startup and exiting
On 2007-04-27, Thomas Dickey <dickey@saltmine.radix.net> wrote:[color=blue]
> Andrew Smallshaw <andrews@sdf.lonestar.org> wrote:
>[color=green]
>> Try connecting via ssh instead of telnet or rlogin. The ssh protocol
>> has the ability to advise of changes in terminal size dynamically:
>> telnet doesn't. I'm currently typing this from PuTTY connected to[/color]
>
> any reasonably recent telnet implements NAWS
>
> [url]http://www.faqs.org/rfcs/rfc1073.html[/url][/color]
I just tested this and you are of course quite right. I remember
thinking when I typed that "do I need to double check this?" I
decided no - telnet's been around 35 years, they'd never considered
resizable windows back then. Teach me to be more careful in future.
;-)
--
Andrew Smallshaw
[email]andrews@sdf.lonestar.org[/email]