Tech Support > Operating Systems > IBM OS/2 Warp > VIM for OS/2 Question
VIM for OS/2 Question
Posted by jch on June 21st, 2008


_____
Hello All OS/2 Users,

Just installed VIM v7.0. Works well. Two questions:

1) When i run vim from a 4OS2.EXE shell, i get nice colours, and the
..vimrc file is sourced correctly from the directory above the vim70
directory. When i run vim from a regular CMD.EXE shell i get no
colours, and the .vimrc file is /not/ sourced. Any idea why this is so?

2) How would i structure an OS/2 command file to automatically create a
80x45 sized window (using mode 80,45) after starting 4OS2.EXE, and
launch vim? I keep winding up running CMD.EXE which does not give my
colour and read .vimrc properly.

--
Regards / JCH

Posted by jch on June 21st, 2008


jch wrote:
Found one "work-around". I specified the 4os2.exe program as the os2
shell in the config.sys file like this:
=====
rem -> set os2_shell=c:\os2\cmd.exe
set os2_shell=c:\4os2\4os2.exe
=====

Are there any adverse consequences to this method? I can still run the
regular command shell from 4os2 with "cmd.exe".
--
Regards / JCH

Posted by Alex Taylor on June 21st, 2008


On Sat, 21 Jun 2008 01:23:17 UTC, jch <jch@nowhere.net> wrote:

WAG, but maybe either the HOME or VIM environment variable is pointing
somewhere incorrect under CMD?

--
Alex Taylor
Fukushima, Japan
http://www.socis.ca/~ataylo00

Please take off hat when replying.

Posted by Steven Levine on June 21st, 2008


In <mdq090pMZSKk-pn2-Id2Y9V37sJdQ@localhost>, on 06/21/2008
at 07:29 AM, "Alex Taylor" <mail.me@reply.to.address> said:

Hi,

That would be my guess. It's possible you have multiple .vimrc files and
the shell is causing the selected file to vary.

:version
:set option?
:echo expr...

can help here.

If would also check for 4OS2 aliases, just in case.

That said. I see no differences between 4OS2 and CMD here.

Steven

--
--------------------------------------------------------------------------------------------
Steven Levine <steve53@earthlink.bogus.net> MR2/ICE 3.00 beta 11pre14 #10183
eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
--------------------------------------------------------------------------------------------


Posted by Steven Levine on June 21st, 2008


In <YX_6k.15611$kx.10496@pd7urf3no>, on 06/21/2008
at 03:54 AM, jch <jch@nowhere.net> said:

Hi,

Not in my opinion. I've run this way for many years. There are a couple
of apps that much be installed under cmd.exe because the parse the output
the ver command, but shelling to cmd.exe solves this problem

Steven

--
--------------------------------------------------------------------------------------------
Steven Levine <steve53@earthlink.bogus.net> MR2/ICE 3.00 beta 11pre14 #10183
eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
--------------------------------------------------------------------------------------------


Posted by Steven Levine on June 22nd, 2008


In <9KY6k.40249$gc5.1734@pd7urf2no>, on 06/21/2008
at 01:23 AM, jch <jch@nowhere.net> said:


Use the following 4OS2 script to set the window size to any valid value
and then invoke vim.


Steven

--
--------------------------------------------------------------------------------------------
Steven Levine <steve53@earthlink.bogus.net> MR2/ICE 3.00 beta 11pre14 #10183
eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
--------------------------------------------------------------------------------------------
@echo off
:: winsize - Set VIO window size given rows/columns

:: Copyright (c) 2005, 2007 Steven Levine and Associates, Inc.
:: All rights reserved.

:: This program is free software licensed under the terms of the GNU
:: General Public License. The GPL Software License can be found in
:: gnugpl2.txt or at http://www.gnu.org/licenses/licenses.html#GPL

rem $TLIB$: $ &(#) %n - Ver %v, %f $
rem TLIB: $ $

:: 06 Apr 05 SHL Baseline
:: 15 Sep 05 SHL Suppress info
:: 26 Sep 07 SHL Clear after change

on errormsg pause
setlocal

set R=
set C=

:: Evaluate args, I=num A=value X=scratch

if "%1" == "" goto Usage

do I = 1 to %[%=#]

set A=%[%I]

:: Process switch options
set X=%@substr[%A,0,1]
iff "%X" eq "/" .or. "%X" eq "-" then
:: Got switch
set X=%@lower[%@substr[%A,1,1]]
if "%X" == "h" .or. "%X" == "?" goto Help
iff "%X" == "?" then
echo Switch %X unexpected
goto Usage
else
echo Switch %X unexpected
goto Usage
endiff
iterate
endiff

:: Process arguments
iff %@numeric[%A] != 1 then
echo Argument %A must be numeric
goto Usage
endiff

iff %A ge 80 then
iff "%C" == "" then
set C=%A
elseiff "%R" == "" then
set R=%A
else
echo Argument %A unexpected
got Usage
endiff
else
iff "%R" == "" then
set R=%A
elseiff "%C" == "" then
set C=%A
else
echo Argument %A unexpected
got Usage
endiff
endiff
enddo

if "%R" == "" set R=%_ROWS
if "%C" == "" set C=%_COLUMNS

iff %R gt %C then
set X=%R
set R=%C
set C=%X
endiff

mode co%C,%R

:: font and border specs
set FX=6
set FY=14
set BX=8
set BY=25

set CX=%@eval[%FX*%C+%BX]
set CY=%@eval[%FY*%R+%BY]

:: echo _XPIXELS %_XPIXELS
:: echo _YPIXELS %_YPIXELS
:: echo FX %FX
:: echo FY %FY
:: echo CX %CX
:: echo CY %CY

set X=%@int[%@eval[(%_XPIXELS-%CX)/2]]
if %X lt 0 set X=0
set Y=%@int[%@eval[(%_YPIXELS-%CY)/2]]
if %Y lt 0 set Y=0

option //windowstate=standard
option //windowwidth=%CX //windowheight=%CY //windowx=%X //windowy=%Y //windowstate=custom
cls

quit

:: end Main

::=== Usage: Report usage error ===

:Usage
beep
echo Usage: %@lower[%0] `[rows [columns]]`
cancel
:: end Usage

:Help
echo.
echo Usage: %@lower[%0] `[rows [columns]]`
echo.
echo ` -? This message`
echo.
echo ` row window rows/columns`
echo ` columns window column/rows`
echo.
echo ` args assumed to be reversed if first arg 80`
cancel
:: end Help

:end



Posted by jch on June 22nd, 2008


Steven Levine wrote:

Steven,

Thanks for this script. Will check it tomorrow.

I did ":ver" in vim, and noted what environment variables should be set.
I added to CONFIG.SYS:
set VIM=c:\vim\vim70
set HOME=c:\vim\vim70

Then i put my .vimrc and .viminfo files in c:\vim\vim70. All colours,
and settings in the .vimrc file are present! Thanks again for the hint.
--
Regards / JCH

Posted by Dave Yeo on June 22nd, 2008


On 06/21/08 11:51 pm, jch wrote:
Really HOME could be set to something more generic, perhaps c:/home
(note slash instead of backslash) as lots of programs, mostly unix ports
but even the most recent Mozilla apps and Cairo apps like Doodles
screensaver will use %HOME% to save configuration info. You will see
files and/or directories starting with a dot. These under *nix would be
hidden files.
Dave

Posted by Marty on June 22nd, 2008


Steven Levine wrote:
Move commands happen very differently between the two, but install
scripts very rarely use those. I recall some older threads (Google
should help) about applications which wouldn't run or install because
4os2 was the main shell. Easy enough to work around for the few cases.

--
[Reverse the parts of the e-mail address to reply.]

Posted by Steven Levine on June 23rd, 2008


In <oDm7k.46007$gc5.2915@pd7urf2no>, on 06/22/2008
at 06:51 AM, jch <jch@nowhere.net> said:

I agree with Dave that you should use something generic like

set HOME=c:\home

It will make it easier for VIM to interoperate with other applications
which use HOME to locate their configuration files.

Steven

--
--------------------------------------------------------------------------------------------
Steven Levine <steve53@earthlink.bogus.net> MR2/ICE 3.00 beta 11pre14 #10183
eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
--------------------------------------------------------------------------------------------


Posted by jch on June 23rd, 2008


Steven Levine wrote:
Thanks for feedback.

Now have set VIM=c:/vim/ <- points vim to c:\vim\.vimrc
and set HOME=c:/home <- points vim to c:\home\.viminfo

Get correct vim behaviour with CMD.EXE and 4OS2.EXE. I still have to
understand how to run a 4OS2 script automatically. Any hints? Still
have to read through the 4OS2 docs.
--
Regards / JCH

Posted by Steven Levine on June 23rd, 2008


In <sgT7k.22628$kx.8831@pd7urf3no>, on 06/23/2008
at 07:59 PM, jch <jch@nowhere.net> said:

Hi,

It depends on what you mean by automatically. With 4OS2 installed to
d:\usr\bin, the following in config.sys

SET OS2_SHELL=D:\USR\BIN\4OS2.EXE
SET COMSPEC=D:\USR\BIN\4OS2.EXE

makes 4OS2 the default shell.

Steven

--
--------------------------------------------------------------------------------------------
Steven Levine <steve53@earthlink.bogus.net> MR2/ICE 3.00 beta 11pre14 #10183
eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
--------------------------------------------------------------------------------------------


Posted by Dave Yeo on June 23rd, 2008


On 06/23/08 12:14 am, Steven Levine wrote:

This always brings up the question of which to use, backslashes or
normal slashes with %HOME%.
I've always used slashes on the principal that *nix programs are more
likely to be happy and the only problem I've come across was that the
Gnome port needed backslashes to startup.
Dave

Posted by jch on June 24th, 2008


Steven Levine wrote:

Forgot to set COMSPEC= ; done

I realised that your 4OS2 script to set the window size is a 4OS2 batch
file. I called it WSIZE.BTM. Created a new program object. When i put
in the parameter field "C:\4OS2\WSIZE.BTM 45 80", 4OS2 starts up with
the window size i want.

To open VIM in a window of a specified size i use two simple OS/2
command files i found on the net:

VIMBIG.CMD:
@echo off
start "Vi Improved" /f vimbig2.cmd %1 %2 %3 %4

VIMBIG2.CMD:
@echo off
mode 80,45
vim.exe %1 %2 %3 %4
exit

The only "problem" i have with the VIMBIG.CMD command files is that it
does /not/ open a file for editing when it happens to be a "shadow" and
i drop it on the VIMBIG.CMD icon. When i drop the real file on the
VIMBIG.CMD icon, all works as desired.
--
Regards / JCH

Posted by Steven Levine on June 24th, 2008


In <gtW7k.982$2G6.845@edtnps83>, on 06/23/2008
at 11:37 PM, Dave Yeo <dave.r.yeo@gmail.com> said:

Hi,

There's no good answer for this. While native apps should not care, I've
run across some that fail to handle slashes transparently, so I use
backslashes in config.sys.

If I need to use forward slashes, I typically handle this in a wrapper
script. 4OS2 makes this relatively easy, so I use commands like

set SANE_CONFIG_DIR=%@replace[\,/,%HOME]/.sane


Steven

--
--------------------------------------------------------------------------------------------
Steven Levine <steve53@earthlink.bogus.net> MR2/ICE 3.00 beta 11pre14 #10183
eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
--------------------------------------------------------------------------------------------


Posted by Steven Levine on June 24th, 2008


In <t7Y7k.23098$kx.4901@pd7urf3no>, on 06/24/2008
at 01:31 AM, jch <jch@nowhere.net> said:

Hi,

:-)

It is named winsize.cmd here only because 4DOS does not support window
resizing. I reserve .btm for scripts that will run under both 4dos or
4os2, but that's just my style.

This will get you scroll bars if you are not running your VIO windows
maximized. My equivalent is

call wsize.btm 80 45
vim.exe %$

because I almost never run VIO windows maximized.

This is just the way the WPS works. It's a somewhat odd limitation, but
it's been there forever. Someone would need to implement an enhanced
program object to support this. Someone may have already done this, but
if so, I'm not aware of it.

Steven

--
--------------------------------------------------------------------------------------------
Steven Levine <steve53@earthlink.bogus.net> MR2/ICE 3.00 beta 11pre14 #10183
eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
--------------------------------------------------------------------------------------------


Posted by Paul Ratcliffe on June 24th, 2008


On Tue, 24 Jun 2008 10:31:37 -0700, Steven Levine <steve53@earthlink.bogus.net>
wrote:

I tried dropping a shadow of a data file on to a shadow of the Enhanced Editor
(EPM) and it opened the file. I also tried dropping it on a shadow of the
System Editor and it also opened the file.
Is this just a batch file problem?

Posted by jch on June 24th, 2008


Paul Ratcliffe wrote:
Paul,

I can duplicate what you observed: drop shadow of text file onto shadow
of E.EXE, and text file opens just fine. Dropping shadow of text file
onto shadow of command file does nothing, while dropping the actual
object onto command file acts on it correctly and opens the file.

Interesting! Learning little tid-bits all the time about OS/2 after
many years of "rest".

/ John

--
Regards / JCH

Posted by Steven Levine on June 25th, 2008


In <slrng62p4i.903.abuse@news.pr.network>, on 06/24/2008
at 09:18 PM, Paul Ratcliffe <abuse@orac12.clara34.co56.uk78> said:

Hi,

Forget it. Brain cramp. Shadows of physical objects are not a problem.
It's abstract objects that don't drop as one might wish.

It is most likely a script problem.

Steven

--
--------------------------------------------------------------------------------------------
Steven Levine <steve53@earthlink.bogus.net> MR2/ICE 3.00 beta 11pre14 #10183
eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
--------------------------------------------------------------------------------------------