bug on vim display when lines and columns are set

79 views
Skip to first unread message

leandromartinez98

unread,
Oct 10, 2008, 4:05:22 PM10/10/08
to vim_use

I'm using Ubuntu 8.04 and Vim 7.1.138.

I've set in my ~/.vimrc file the following:

set lines=48 columns=80

In order that Gvim opens with that display properties. This works
fine.

However, now, when I use "vim" from a Terminal (terminal emulator
for the Gnome desktop, version 2.22.1), and open vim, the display
shows the file displaced in some strange way, in such a way that
the line being edited is not the line being displayed.

That means, for example, that if I search a pattern in my file, it
will apparently move through the file as it is going to the next
pattern positon, but the actual display of the file is not showing
the right file position, the cursor standing in places where
there is nothing written, for instance, or anywhere else.
It seems that the display and editing buffers
are not synchronized.

Removing the "set lines..." resolvs the issue, but then gvim opens
with the standard size (which is less terrible, but I would like that
to work well).

Does someone observe the same behavior?

Thanks,
Leandro.

Tony Mechelynck

unread,
Oct 10, 2008, 8:00:35 PM10/10/08
to vim...@googlegroups.com

The vimrc is sourced by both gvim and Console Vim; however, not every
console terminal can be resized by the program running in them. In those
which can't, weird things can happen if you try; and even if your
terminal can be resized, I supposed you'll probably prefer to resize it
by methods external to Vim, such as dragging one corner of the xterm,
konsole, gnome-terminal, Terminal.app, cmd.exe or similar window.
Therefore I recommend wrapping that command as follows:

if has('gui_running')
set lines=48 columns=80
endif

in order to only apply the ":set" command when we already know that we
are starting the GUI.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
207. You're given your one phone call in prison and you ask for a laptop.

leandromartinez98

unread,
Oct 13, 2008, 10:36:25 AM10/13/08
to vim_use

Hi Tony,

Thank you very much for your answer, the conditional setting of the
lines totally solves the issue.

I was aware of Vim reading the .vimrc file and I never expected Vim to
resize
my terminal window because of those options. I was expecting, on the
other
side, that that line was considered only in the GUI case. The fact
that those
lines are read and cause a weird behaviour should be avoided, since
weird
behaviours are always undesirable. But, anyway,
since that simple solution is available, this is not a great issue.

Thanks again,
Leandro.



On Oct 10, 9:00 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:

Tony Mechelynck

unread,
Oct 13, 2008, 10:44:17 AM10/13/08
to vim...@googlegroups.com
On 13/10/08 16:36, leandromartinez98 wrote:
>
> Hi Tony,
>
> Thank you very much for your answer, the conditional setting of the
> lines totally solves the issue.
>
> I was aware of Vim reading the .vimrc file and I never expected Vim to
> resize
> my terminal window because of those options. I was expecting, on the
> other
> side, that that line was considered only in the GUI case. The fact
> that those
> lines are read and cause a weird behaviour should be avoided, since
> weird
> behaviours are always undesirable. But, anyway,
> since that simple solution is available, this is not a great issue.
>
> Thanks again,
> Leandro.

Some terminal emulators can be resized (not that I'd recommend it); if
run in that kind of terminal, Console Vim can resize it.

Best regards,
Tony.
--
Gosh that takes me back... or is it forward? That's the trouble with
time travel, you never can tell."
-- Doctor Who "Androids of Tara"

Matthew Winn

unread,
Oct 14, 2008, 2:10:58 PM10/14/08
to v...@vim.org
On Mon, 13 Oct 2008 07:36:25 -0700 (PDT), leandromartinez98
<leandrom...@gmail.com> wrote:

> I was aware of Vim reading the .vimrc file and I never expected Vim to
> resize
> my terminal window because of those options. I was expecting, on the
> other
> side, that that line was considered only in the GUI case. The fact
> that those
> lines are read and cause a weird behaviour should be avoided, since
> weird
> behaviours are always undesirable.

Those options predate the GUI. They come from the original vi, and
were used to allow users to tell vi how large a screen it was running
on. With the introduction of the GUI in Vim it became possible for
setting those options to change the size of the window, but they still
need to be available in the non-GUI environment so people can tell Vim
how much space is available to it. If you set them to values that
don't match the real terminal size there's not much Vim can do about
it except trust that you know what you're doing.

--
Matthew Winn

Gary Johnson

unread,
Oct 14, 2008, 3:25:25 PM10/14/08
to vim...@googlegroups.com

I discovered when running vim in an xterm under KDE that setting
'lines' and 'columns' resizes the xterm, so these settings are not
just for gvim and for adjusting vim to the size of the terminal.

Regards,
Gary

Reply all
Reply to author
Forward
0 new messages