What's the difference between no{option} and inv{option} in Vim? - vim

I read the documentation and I can't figure out what makes them different.
:se[t] no{option} Toggle option: Reset, switch it off.
:se[t] {option}! or :se[t] inv{option}
Toggle option: Invert value. {not in Vi}
For example, I thought that if I used :set noic therefore I shouldn't be able to :set invic because the option is disabled altogether as there's nothing to invert.
But apparently, you can still invert it.

"Invert" means make it the opposite of what it is now — turn it on if it's off, or off if it's on.

Related

Hide vim cmdline

I know this is a little OCD, but now that I've tricked out my vim and tmux configs, I'm curious if it's possible to collapse the empty vim cmdline when not in use. It just sits there taking up a precious line of vertical real-estate!
From :help cmdheight:
'cmdheight' 'ch' number (default 1)
global
{not in Vi}
Number of screen lines to use for the command-line. Helps avoiding
hit-enter prompts.
The value of this option is stored with the tab page, so that each tab
page can have a different value.
set cmdheight argument must be positive, so no, it's not possible to hide the cmdline.
In Vim 9.0.0114 and Neovim 0.8 (prerelease), set cmdheight=0 hides the command line.

spf13-vim disable tab highlighting

I'm an absolut vim-newbie so I thought I'll try it with some preconfigured distribution like spf13-vim. So to my question, I would like to disable the "tab-highlighting" because I find it kind of distracting...
I think this picture should make clear what I mean
Put a line below in your ~/.vimrc.local or ~/.vimrc.before.local to disable indent guide by default. You can <leader>ig as well.
let g:indent_guides_enable_on_vim_startup = 0
You can toggle them on/off with ,ig.
write set nolist in your .vimrc.local to turn it off.
see :h list
'list' boolean (default off)
List mode: Show tabs as CTRL-I is displayed, display $ after end of
line. Useful to see the difference between tabs and spaces and for
trailing blanks. Further changed by the 'listchars' option.

How do you undo setting an option in vim?

I often call
:set spell
only to immediately call
:set nospell
once I've corrected the word I was unsure of.
I can make this faster by mapping both commands, but I'm looking for a more general way to speed this up. Is it possible to undo the last option :set?
Strictly speaking, no, you cannot undo setting a setting in Vim.
But boolean options like 'spell' can be toggled with either one of
:set spell!
:set invspell
In interactive use there is generally no need to specifically :set spell or :set nospell. Toggling is more convenient and can be immediately "undone" with the #: command.
Non-boolean options can be undone by resetting them to their factory values – say, if you have messed up some setting and wish to revert. Example:
:set formatoptions&
A & appended to the option name resets it to its default value.
I don’t know that you can undo the setting of an option, but in the case of an on / off option such as spell, you can toggle it with a ! at the end of the option name:
:set spell!

how to autocomplete options in vim command mode

my setting for command mode completion is:
set wildmenu
set wildmode=longest,list,full
currently when i type
:set fdm=
in command mode, then press tab, manual appended, if i Press tab again , character ^I appended, what i want is manual changed to another foldmethod options such as syntax, indent and so on.
does anyone know is that possible or if there is any plugin could do that ?
thanks !
As you say, when you press <Tab> after :set fdm=, you get manualinserted.
That could seem the usual autocomplete behaviour we are used to in many places, manual being just the first of all possible values. So, you expect that repeating <Tab> will give you more possibilites.
But that's not indeed the case. What you get when pressing <Tab> in such a situation is not the first autocompletion alternative, but the current option value. So, you're getting manual because that's in fact the default value for that option. Successive <Tab>s get inserted literally, as this behaviour is only fired right after =.
From Vim's help:
The old value of an option can be obtained by hitting 'wildchar' just after
the '='. For example, typing 'wildchar' after ":set dir=" will insert the
current value of 'dir'. This overrules file name completion for the options
that take a file name.
So, what you described is expected behaviour. See :help cmdline-completion for the whole story.
I don't know about any plugin capable of changing this to what you want.

Is it possible to not display a ~ for blank lines in Vim/Neovim?

Is it possible to not display a ~ for blank lines in Vim?
This confuses Mac Vim's scrollbar, and I quite don't like these tildes.
:hi NonText guifg=bg
That command should set the color of non text characters to be the same as the background color.
Vim 8.x:
You can now change the color just for the end of the buffer ~:
highlight EndOfBuffer ctermfg=black ctermbg=black
See changelog for Vim 8.x.
As jamessan said, you can’t disable them. The scrolling behavior isn’t specific to MacVim, either — it works the same way in the terminal and in gvim:
Instead of seeing this as a problem, what you should do is learn to see this as part of Vim’s flexibility. For example, you can use the zt command to scroll the current line to the top of the screen, regardless of where in the file it is. This can make it easier to write macros that do some work and then scroll back to where you were. The commands <C-E> and <C-Y> are made simpler because of this, as is the 'scrolloffset' option.
If you must, retrain your brain to think of Vim’s scrollbar as mapping to which line is on top, instead of which screenful is visible.
For NeoVim, you can set the fillchars value for eob to a space character and that will effectively hide it. (This might not work for plain Vim).
In Lua (Nvim 0.5+):
vim.wo.fillchars='eob: '
In VimScript:
set fillchars=eob:\
Note: Calling the above will override your fillchars value for other items as well (if set), so use this as a reference to set multiple values together:
set fillchars=eob:\ ,fold:\ ,vert:\│
Or use set fillchars+=... to append it your existing values.
You can't disable them, but you can change your colorscheme such that the NonText highlight group is colored the same as the Normal highlight group. However, this affects more than just the end of document tildes.
I doubt that it's actually "confusing" MacVim's scrollbar and if it is, then that's a bug in the patching that MacVim does.
The tilde ~ characters are meant to remind the user that those lines are not part of buffer content.
The above highlight trick will hide the ~ character, but it is still there. For some terminals, this may not even work. If you happen to be a Neovim user, you can use fillchars option to change the end of buffer symbol like this:
set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾
This will use space instead of ~ for end of buffer, effectively hiding the annoying ~.
You may also be interested in discussions here.

Resources