Skip to main content

Questions tagged [options]

For questions about runtime settings that modify the behavior of the editor. When applicable, tag the version of the editor.

Filter by
Sorted by
Tagged with
12 votes
1 answer

How do I use a variable or return value in option, command, or mapping?

I have a variable foo with let foo='value', and a function F like function F() return 'value' endfunction and I want to use them in an option: :set option=foo, :set option=F(); or in a command: :...
D. Ben Knoble's user avatar
  • 26.6k
22 votes
3 answers

The simplest way to start Vim in private mode

I want to be able to easily start Vim in a private mode. Let's define a private mode as one that utilizes this set of commands: set history=0 set nobackup set nomodeline set noshelltemp set ...
Mateusz Piotrowski's user avatar
13 votes
2 answers

Showing command history with showcmd

When using set showcmd Vim shows partial commands in the last line of the screen. For example, in Normal mode when typing the command dt. the last line shows dt and then, when you hit . the command is ...
Gonçalo Ribeiro's user avatar
19 votes
4 answers

Set the paste option, but for one insertion only

I want to have a quick way of setting the Vim 'paste' option, inserting some text, and reverting to the previous value of 'paste'. A typical use case insert the OS clipboard content literally, ...
Gilles 'SO- stop being evil''s user avatar
12 votes
2 answers

`set` option with variables

I am trying to rewrite adding a string to option with variable. The original string is set rtp+=~/.vim/bundle/Vundle.vim The following is the working let way: let MYVIMDIR='/home/loom/foo' let &...
Loom's user avatar
  • 261
3 votes
1 answer

showcmd on first line instead of last line

From the help file for showcmd: Show (partial) command in the last line of the screen Is it possible to have the commands displayed on the first line instead? I can't find anything in the help or ...
notAlex's user avatar
  • 131
43 votes
3 answers

When to use the after/ directory?

I understand it's the place to put things that should have the final say and not be overridden by another source, but I'm unclear on how to decide when to put something in, say, ~/.vim/after/ftplugin/ ...
ivan's user avatar
  • 1,470
34 votes
3 answers

How to apply a setting in all open tabs and windows?

Is there an option to apply a setting in all tabs and windows, e.g. apply :set number to all open tabs?
vfclists's user avatar
  • 897
20 votes
4 answers

How can I suppress the "reading from STDIN" message from within Vim?

When using Vim to read from stdin, it prints a informative message: $ echo foo | vim - Vim: Reading from stdin... $ This is just an example. The actual use doesn't allow shell constructs. vim <(...
muru's user avatar
  • 25k
14 votes
2 answers

Advice to add `set nocompatible` as first line of .vimrc

I recall (perhaps in the early 2000's) having set nocompatible as the first line of my vimrc and most Vim guides and tutorials recommending that practice. Some examples I could easily find online: ...
filbranden's user avatar
  • 29k
8 votes
7 answers

Is there a vim command line option to edit last edited file?

Is there a way to run vim from command line to edit the last edited file? Let say I first edit file $ vi Afterwards, I exit back to terminal $ do something... $ do something ...
Giorgio Robino's user avatar
7 votes
1 answer

How to show trailing spaces, while leaving tabs as they are?

I like the ability to show trailing whitespaces, so I have this setting. set list listchars=tab:\ \ ,trail:· I never use tabs (although I don't think tabs are bad, it's just a convention), but ...
user1685095's user avatar
  • 1,151
7 votes
1 answer

Why are tabs adjacent to concealed tabs displayed wider than a single tabstop?

I just wrote the following code in an answer to another question: syntax match HideTwoIndents /\v^\t(\t)?/ conceal set conceallevel=2 This works great if 'list' is set and if 'listchars' does not ...
Rich's user avatar
  • 32.2k
6 votes
1 answer

remove from comma-separated option (listchars)?

I don't do tabs, so usually my listchars=tab:▸ ,nbsp:␠,trail:·,precedes:«,extends:» But it gets annoying with some sources. I'd like to subtract tab: from lcs in some filetypes. I've tried setlocal ...
usretc's user avatar
  • 374
4 votes
1 answer

How can I use the return value of a function in a :set command?

I want to set an option to a string containing full path of current working directory. For example set tags=getcwd()."\tags" " retrieve the full path of the tags file in current ...
Eric Sun's user avatar
  • 198
2 votes
2 answers

set formatprg dynamically based on textwidth?

I've set formatprg in my vimrc to use the par text formatter when I type gq. setg formatprg=par\ -w90 When I'm in a buffer whose textwidth has been set (e.g. the gitcommit filetype sets textwidth=72)...
ivan's user avatar
  • 1,470
2 votes
1 answer

How to change in gvim GTK file browser the default file mask wildcard (glob)?

In gvim the command :browse confirm e launches a GTK file browser. The default file mask in this window depends on the filetype from which the browse window is invoked. I would like to change that ...
Janek_Kozicki's user avatar
1 vote
1 answer

Can I disable running shell commands in Vim?

I am developing a command line application that uses Vim to edit an existing file. Think visudo or crontab -e. Is there any command line option that I can pass to Vim to disable shell commands?
LiamF's user avatar
  • 185
0 votes
2 answers

How to escape spaces when setting options in vimscript?

I am trying to set an option in my init.vim or .vimrc. Specifically, it is the path variable, and I need to set it to a value that contains spaces; for example, this could be because several of the ...
Tom Warner's user avatar
0 votes
2 answers

Prevent saving buffer with new name

I am developing a command line application that uses VIM to edit an existing file - think visudo or crontab -e When I launch VIM, I'm passing it the path of an existing file. I want the user to be ...
LiamF's user avatar
  • 185
-1 votes
2 answers

What options shall be set for loading ftplugins? [duplicate]

Consider the following script: vim9script filetype plugin indent on import "./plugin/myplugin.vim" exe $"edit" MyCommand In the specific case, ...
Barzi2001's user avatar
  • 640