42
$ vim -c 'set ai'
See :h -c, :h startup and $ vim --help.
26
Generally, if you want to add your own plugin, or replace a standard plugin with your own, it would go into ~/.vim/plugin or ~/.vim/ftplugin. If instead you want to keep the functionality of an existing plugin but add to it, or change just a few settings made by it, then your plugin would go into ~/.vim/after/plugin or ~/.vim/after/ftplugin.
20
Yes, there is! You can accomplish this with :tabdo and :windo. For your case specifically:
:tabdo windo set number
See :help :tabdo and :help :windo for more information.
18
You can use the &{option-name} in an if-statement like so:
if &guioptions ==# "Trl"
echo "Toolbars and scrollbars are present!"
elseif &guioptions ==# ""
echo "No toolbars and scrollbars present!"
endif
The & specifies that the variable name is a Vim option.
See :help :let-& for the full documentation.
15
Give this a try:
function! Paste_Func()
let s:inPaste = &paste
if !s:inPaste
set paste
endif
echom s:inPaste
augroup paste_callback
autocmd!
autocmd InsertLeave <buffer> call Paste_End()
augroup END
startinsert
endfunction
function! Paste_End()
augroup paste_callback
autocmd!
...
14
You can use the built-in :options and :mkvimrc (see :help :options and :help :mkvimrc).
But… creating your own ~/.vimrc is a daunting task only if you want the perfect vimrc "right now". If you are not patient enough, there are dozens of alternative editors with less options and GUI dialogs. Vim is not an editor you can pick up in an afternoon: expect work ...
13
You can use the let command instead.
Like so:
let &shiftwidth = &tabstop
The & specifies that the variable name is a Vim option. You can also do :help let-option to know more about it:
:let &{option-name} = {expr1}
Set option {option-name} to the result of the
expression {expr1}. A String or Number value is
always ...
12
One website for generating .vimrcs is http://vimconfig.com/ . It's fairly basic — just enough to get started on (line numbers, search highlighting, etc.).
12
The answer to your exact question:
Can I suppress that using only Vim options and/or vimrc settings?
is: no, it's not possible because of the following part of the code
if (read_stdin)
{
#ifndef ALWAYS_USE_GUI
mch_msg(_("Vim: Reading from stdin...\n"));
#endif
which means that if you give - as argument to vim, then it'll mechanically ...
12
The reason your example attempts don't work is that in many locations text is simply seen as a literal string, rather than VimScript. So functions, variables, and the like don't work.
For example, if you do:
:let var='value'
:set option=var
Then Vim will simply set the value of option to the literal value var, since it doesn't recognize VimScript in :set. ...
11
You could use :exe, but this is extremely cumbersome to use and you'll need to escape a few things.
I used to use my own path fixing function. It looked like:
exe 'set rtp+='.lh#path#fix(somevariable)
" with standard tools, may be it'd be (untested)
exe 'set rtp+='.escape(somevariable, ' \|,')
let &rtp = expression is really our friend.
But indeed, ...
10
Starting with Vim 8.0.1308 (Nov 2017), you can use the "--not-a-term" option
with "quit":
$ echo hello | vi - --not-a-term -esc '%p|q!'
hello
Or with "exit":
$ echo hello | vi - --not-a-term -esc 'x!/dev/stdout'
hello
http://github.com/vim/vim/issues/1552
10
According to the site Things I have learned about Linux for the Blind, vim has issues unless you :set noruler. According to him, elvis has a screen-reader friendly mode that doesn't use curses.
From what Tyler Spivey (a blind CLI user) wrote,
The problem with these is that a screen reader
doesn’t know that, for example, j will move
the cursor to ...
10
Well, a bit belated but to respond to:
Some magic (from a comment by Carpetsmoker in this thread)
My general idea was that you always want to start "private mode" if you're using an encrypted file, so this autocommand will do that for you:
au BufRead * if &key!= ""
\ | setlocal history=0 nobackup nomodeline noshelltemp noswapfile ...
answered Feb 25 '16 at 8:36
Martin Tournoij
49.7k1919 gold badges158158 silver badges242242 bronze badges
9
I couldn't find any way to do this in a regular Vim. However, if you are willing to patch Vim, the following may work for you.
The very simple patch (applied against Vim-7.4.052) disables the actual update to the screen that clears the history at the end of a normal command. It does this by returning whether or not showcmd_is_clear is set prior to updating ...
9
You can always prefix your search expression with \c to enforce case insensitivity (and \C for case sensitivity). From :h ignorecase:
/\c /\C
When "\c" appears anywhere in the pattern, the whole pattern is handled like
'ignorecase' is on. The actual value of 'ignorecase' and 'smartcase' is
ignored. "\...
8
For this purpose, I have definde the following alias in my shell:
alias lvim="vim -c \"normal '0\""
(l meaning last)
8
From :help :set-args:
White space between {option} and '=' is allowed and
will be ignored. White space between '=' and {value}
is not allowed.
So:
set history=1000 " is ok.
set history =1000 " is also ok, but
set history= 1000 " is not. Neighter is
set history = 1000
If the option doesn't take a value you can put as many spaces behind it as you ...
8
:h gf says:
If the file can't be found, 'includeexpr' is used to
modify the name and another attempt is done.
And for :h includeexpr:
'includeexpr' 'inex'
'includeexpr' 'inex' string (default "")
local to buffer
{not in Vi}
{not ...
8
I'd personally recommend against doing so, but you can use Vim's "line continuation" feature for this:
set number
\ showmatch
\ hlsearch
This will be interpreted by Vim as if the contents of the lines after the backslashes were written at the end of the previous line:
set number showmatch hlsearch
Note that whitespace before the backslash is ...
7
:tabdo windo set number gets the job done, but I don't really like it since it actually switches to each tab and window before running the command. After it finishes running, you'll end up on the last window of the last tab.
I think this is a cleaner way to set options in all windows without changing the current tab and window:
function! s:set_all(option, ...
7
The simple way is
if get(g:, 'myplugin_enable_feature', defaultvalue)
do whatever you want
endif
Now when I need to check a setting in more than one place, I usually prefer to have a dedicated getter in my plugin to be sure I have the same default value everywhere
function! s:enable_feature() abort
return get(g:, 'myplugin_enable_feature', ...
6
I guess the usual trick is to set ignorecase and smartcase and depending on what you need, search using only lower case (which means to ignore the case for that particular search) or search using mixed case, if you need to have the search match the provided case.
The other alternative is to use the '\c' and '\C' atoms when searching (see the help at :h /\c ...
6
1. :mkexrc
The easiest way is to use :mkexrc command. With this command, we can save all changed options into a file. When you need to restore back all the saved options from the file, just:source it.
mkexrc snapshot
source snapshot
2. :set and :redir
The :mkexrc command necessarily uses a file to hold all options.(And it also saves current key mappings....
6
Vim doesn't provide any way to know all possible plugin options.
As a plugin writer I can tell you this is quite complex as there are many different ways to proceed. For instance either we consider that if the end-user hasn't provided a value for an option in its .vimrc then we force this option to exist and to be equal to a default value, or we can say: &...
5
An heavy solution: the sessions
Another possible option is to use the sessions mechanism:
First your vim version has to be compiled with the +mksession option. (Use :echo has('mksession') to check that).
Now when you are about to leave vim, use the following command:
:mksession!
This will create (or overwrite thanks to !) a file named Session.vim in the ...
5
The nomagic setting was created to support the edit mode, which was "designed for more casual or beginning users", rather than as a general "nothing is a metacharacter" mode.
From the ex reference manual:
The ex default setting of magic gives quick access to a powerful set of regular expression metacharacters. The disadvantage of magic is that the user ...
5
You could use an environment variable defined within your current shell session.
let $myvimdir = '/home/abc/vimfiles'
That way you can use other variables to compose the path as well:
let $myvimdir = $HOME.'/vimfiles'
And set the runtime path:
set rtp+=$myvimdir/bundle/Vundle.vim
More information on environment variables within vim :help expr-env
5
From your .vimrc:
...
set cursorline
set " <- HERE
syntax on
...
This set command must be causing it.
Looks like during initialization Vim
dumps output to terminal, but you don't see it until
Vim is closed. I get similar behaviour if I put stray set to my .vimrc
file (although I do need to press enter to skip the output, but this must ...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
options × 89vimrc × 23
vimscript × 10
buffers × 5
command-line × 4
indentation × 4
statusline × 4
set × 4
vim-windows × 3
formatting × 3
variables × 3
line-numbers × 3
startup × 3
key-bindings × 2
neovim × 2
cut-copy-paste × 2
terminal × 2
insert-mode × 2
save × 2
unicode × 2
invocation × 2
encoding × 2
command-history × 2
history-of × 2
load × 2