Why doesn't Vim execute my column setting in this command? - vim

I have a Vim command to enter a "Distraction Free" mode:
command! DistractionFreeMode set guioptions-=r gfn=Cousine:h12 showtabline=0 fullscreen laststatus=0 noruler wrap linebreak nolist linespace=5 foldcolumn=3 nonumber columns=80
Note also that I am using MacVim. The command sort of works, but some of the settings don't seem to be triggered. These include columns=80 and nolist. I always have to set these separately after executing this command in order to get them right. I have also tried putting these settings in a function that I called with the command and had the same issue. What is the source of this problem?
EDIT: Here is a screenshot of the look I'm aiming at. Using fullscreen and columns together is necessary to achieve this, as far as I know:

According for the help for fullscreen (:h fullscreen) There are option to tailor the behavior of what happens when you enter fullscreen mode which are set with fuoptions
On my MacVim fuoptions is set to
fuoptions=maxvert,maxhotz
When we look at :h fuoptions
maxvert When entering fullscreen, 'lines' is set to the maximum number
of lines fitting on the screen in fullscreen mode. When
leaving fullscreen, if 'lines' is still equal to the maximized
number of lines, it is restored to the value it had before
entering fullscreen.
maxhorz When entering fullscreen, 'columns' is set to the maximum number
of columns fitting on the screen in fullscreen mode. When
leaving fullscreen, if 'columns' is still equal to the maximized
number of columns, it is restored to the value it had before
entering fullscreen.
This mean that when you enter fullscreen mode MacVim resizes to to the maximum number of lines and columns it can. (ignoring the values you set)
To fix this you can either add set fuoption-=maxhorz to remove the offending option or add set=maxvert to force it to only use maxvert regardless if other options are set. This stops MacVim from overriding your settings in the horizontal direction.
So your fixed command would look something like
command! DistractionFreeMode set guioptions-=r gfn=Cousine:h12 showtabline=0 fuoptions-=maxhorz fullscreen laststatus=0 noruler wrap linebreak nolist linespace=5 foldcolumn=3 nonumber columns=80

Related

Highlighting lines in vim excluding the row number

I have set number in my vimrc, and I want to highlight rows using my mouse cursor without selecting the row numbers, kinda like how MacVim does it. I understand that MacVim is a native application and vim is bound by the conditions of the shell/terminal that it is in.
Is there a way to make this happen?
I want this:
Not this:
If your terminal supports the mouse (some don't). Adding the following to your vimrc will enable the mouse to be used for visual selections.
set mouse=a

Vim: What is the status bar code for the view of command being entered?

I used to (in less customized vim) get a little field in the status bar that would show me what I was typing as a command, e.g. if I enter 99dd it would display 99d as i typed it in.
Since updating my statusline to something (it used to be unset) this has now disappeared. How can I get it back?
You're looking for
:set showcmd
Actually, it's not inside the statusline, but below, in the space occupied by the command-line (and ruler, if no statusline is visible).
Since this is on by default (except on Unix), you should investigate where it was turned off, and fix it there (or just set it in your .vimrc):
:verbose set showcmd?

vim: cannot click past col 90

Since I'm pretty new with vim, I (still) find the mouse very useful to click somewhere (to move quickly) and select blocks of text.
in my vimrc:
set mouse=a
and also
set textwidth=80
set colorcolumn=80
I can click to move the cursor, but not after the column 91. I really don't understand why this behaviour and why this arbitrary limit.
You are limiting the effective width of your document to 80 columns. No wonder clicking outside of this arbitrary limit - that you choose - does nothing.
To be able to click anywhere, you must
:set virtualedit=all
but it doesn't make much sense if you set hard physical limits to your content.
you can try to set fileencoding and encoding of vim be the same value,
set fileencoding=utf-8
set encoding=utf-8
and make sure your locale is the same value, too.
you can use 'locale' command to get your own locale in a terminal.

How do I make Vim get the number of rows of the terminal from which it starts?

My work setup has several terminals open, at different heights (e.g. number of lines). How do I make Vim obtain that number of lines so that it can set itself accordingly with set lines?
I'm on bash with iTerm2.
Update: If my .vimrc doesn't have a set lines statement, Vim should adjust itself by default.
Vim's default behaviour is to take up all of the available height. Or 24 lines if it can't get the information from the Terminal emulator according to :h lines.
set lines=52 works in MacVim/GVim but it's not really supposed to do anything useful in CLI Vim besides, eventually, changing the terminal's window height.
From my limited use of iTerm2 Vim behaves as it should. So do you want Vim to take less vertical space than what is available? Or more?
Though the reason didn't require it, in case someone comes across this while trying to figure out how to get the number of rows in a terminal at startup... the answer is to use "&lines".
Eg. to enforce laststatus to display unless you are working in a small window.
if &lines > 10 | set laststatus=2 | endif

Vim status line not changing / clearing

No matter what I change status line to with set statusline my status line will not change. It looks like
".vimrc" 39L, 578C 1,1 All
with the cursor position and the percentage through the file as well as the filesize and filename. It is the only line at the bottom.
How to I hide or change the status line?
How do I clear the status line?
Why is the status line not working?
What you are looking at is a ruler - a "statusline" in a way, but not a statusline. What can be changed in it you can see in help rulerformat.
If you wish to hide the ruler set set noruler, and afterwards enable the statusline with set laststatus=2 if you wish for every window to have their own statusline (the most common). Depending on what you want in your statusline, you might wish to read help statusline, and afterwards put it in set statusline=... (when adding options add them with set statusline+=... one by one - that way you can more easily turn some on or off).
As the first line, when setting statusline, set set statusline= that way statusline is cleared before it is loaded again. You'll figure this out when you source it the first few times.
What you are looking at is the ruler. You can get rid of it with
:set noruler
However, if you want to customise it, you can use
:set rulerformat=
and follow the same format as the status line.
To hide the status bar use:
:set laststatus=0

Resources