We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

33

$ vim -c 'set ai' See :h -c, :h startup and $ vim --help.


18

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.


16

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.


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! ...


13

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.


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 ...


13

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 ...


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 ...


11

One website for generating .vimrcs is http://vimconfig.com/ . It's fairly basic — just enough to get started on (line numbers, search highlighting, etc.).


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 ...


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

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 ...


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 ...


7

For this purpose, I have definde the following alias in my shell: alias lvim="vim -c \"normal '0\"" (l meaning last)


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

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: "...


6

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, ...


6

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. ...


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

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....


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 ...


4

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 ...


4

Personally, I use the yo keybinding from Tim Pope's excellent vim-unimpaired plugin for exactly this reason. From his documentation: A toggle has not been provided for 'paste' because the typical use case of wrapping of a solitary insertion is so wasteful: You toggle twice, but you only paste once (YOPO). Instead, press yo or yO to invoke |o| or |...


4

except that I want to end up with the 'paste' still active if it was active beforehand. 'paste' should be active for as short a time as possible. It disables a lot of functionality (including maps), because its sole purpose is to avoid misinterpreting text that is being pasted. As such, I think the quoted requirement shouldn't really be necessary. That ...


Only top voted, non community-wiki answers of a minimum length are eligible