Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
6 votes
Accepted

How do I undo the result of the remap of ( to ()?

You can bypass mappings (among other things) with Ctrl-V: <C-v>( should enter a ( without executing the mapping.
D. Ben Knoble's user avatar
  • 26.4k
5 votes
Accepted

Order of sourcing scripts

The reason that the user ftplugin is sourced early is so you can entirely replace the runtime's file with your own. In order to do so, you need to set the b:did_ftplugin in your copy to prevent the ...
Rich's user avatar
  • 32.1k
4 votes
Accepted

Why doesn't echo % do anything in command mode?

So, you found :help current-file: As long as you don't write the buffer, the original file remains unchanged. If you start editing a file (read a file into the buffer), the file name is remembered as ...
romainl's user avatar
  • 41k
4 votes
Accepted

How can I extend syntax highlighting with my own keywords?

The correct filetype for JavaScript is javascript, so your file, which corresponds to a non-existing js filetpe, will never be sourced automatically. It should be: ~/.vim/syntax/javascript.vim Vim ...
romainl's user avatar
  • 41k
4 votes
Accepted

A map command not working correctly in Vim

Check if it happens with vim -Nu NONE. I suspect that you have set paste in your configuration. If it is, unset it and check if your mapping would work. Excerpt from :h 'paste' 'paste' boolean ...
Maxim Kim's user avatar
  • 13.5k
4 votes
Accepted

How do I Conditionally Execute an autocmd Based on the File Extension?

You can simply do: autocmd BufWritePre * if &ft!='markdown' | %s/\s\+$//e | endif Rationale: you can't express a negative/exclusion in an autocommand pattern so the usual approach is to match on ...
Vivian De Smedt's user avatar
3 votes
Accepted

Quit Vim when Buffer has no name (not :wq or :q!)

Here are a few variations on the :help 'buftype' theme suggested by Heptite. The idea is the opposite of that in Pixelbog's answer: instead of changing the behavior of :q, we change the nature of the ...
romainl's user avatar
  • 41k
3 votes

Quit Vim when Buffer has no name (not :wq or :q!)

If you set 'buftype' to nofile the buffer will be considered a "scratch buffer" and you won't have to force quit on the buffer, but you also won't be able to write it if you want to save it.
Heptite's user avatar
  • 1,066
3 votes
Accepted

Error when using vim-plug from git-bash

As pointed out by romainl in the comments, you have two versions of Vim installed: Vim 9.0 with GUI for Windows you probably installed yourself Vim 8.2 without GUI that came on top of git-bash (on a ...
Friedrich's user avatar
  • 2,033
3 votes

How do I undo the result of the remap of ( to ()?

If you usually want to insert the closing parenthesis and occasionally don't want it to be added, you could define another mapping such as inoremap (( ( This will allow you to type a single opening ...
Friedrich's user avatar
  • 2,033
3 votes
Accepted

Is user vimfiles/after/ftplugin supposed to be after system/indent?

Let's start with a blank vimrc: " Hello, world! Vim doesn't do any filetype-specific stuff by default: no ftplugins, no syntax highlighting, nothing. We can tell Vim to start doing filetype-...
romainl's user avatar
  • 41k
2 votes

Don't use scrolloff=5 for mouse clicks

One of the beautiful things about Vim is that often this kind of customisation is not only possible, but relatively straightforward: function! DisableScrollOff() abort " Save the current ...
Rich's user avatar
  • 32.1k
2 votes

tabs after pastetoggle instead of spaces

I only use paste mode when I want to paste the origin text without modifying anything.(like indenting) After pasting, I leave paste mode and starting editing. IMO, you should not hack paste mode, ...
Lotus's user avatar
  • 21
2 votes

How to detect IntelliJ/IdeaVim in vimrc?

Since IdeaVim 1.8.0 you can use the following condition: has("ide"). This works because IdeaVim supports VimScript for several years since 1.7.0. Wrap the lines you want to make conditional ...
Vladimir Parfinenko's user avatar
2 votes
Accepted

Hide the list of plugins show almost each time at a file open

And I found the bug. I basically did this: tried without plugins and/or without vimrc (--noplugin, -u NONE, -u NORC). This showed that it is not some plugin (the list appeared with --noplugin). Then I ...
Artyom's user avatar
  • 127
2 votes

ALE Code Action for python

I'm not aware of a Vim plugin that provide fix for warning detected by the linter. But for automatic correction of missing Python import you could be interested by autoimport You can fix the import ...
Vivian De Smedt's user avatar
2 votes
Accepted

What is `normal! zvzz` in vimscript?

The normal command simulate keyboard input in normal mode. The normal! version ignore the custom mapping that could have been introduced such that its behavior does not depend on special customization ...
Vivian De Smedt's user avatar
2 votes
Accepted

Vim with terminal inside, I have to quit using a vim cmd as the terminal will prevent me from exiting, so I can't do :wq

I got what I wanted by doing: :w|:Q For context Q is a command in my ~/.vimrc: command Q qa! All the steps to write and exit vim with terminal inside: On terminal: vim --clean "+term" &...
Nickotine's user avatar
  • 202
2 votes

Run a Vim command _after_ loading vimrc, but _before_ opening the file?

Here is a low-tech approach. In your vimrc, put all the relevant options behind a guard. Something like: if !exists('$LARGE_FILE') set backup " etc. endif If the environment variable ...
romainl's user avatar
  • 41k
2 votes

Apply local setting to .vimrc

You could always add a plugin to your runtime: ~/.vim/plugin/local_vimrc.vim Another option would be to simply source a file in your vimrc file: if filereadable(expand('~/.vimrc.local')) source ~/....
Peter Rincker's user avatar
2 votes

Why is Vim ignoring my `expandtab` setting?

As you figured out, the problem was that the option was set as a result of setting another option. I opened an issue about this, and the Vim developers sprang into action and fixed it a few days later....
Rich's user avatar
  • 32.1k
2 votes

I want to see my vimrc code but instead, runtime vimrc text is shown

$HOME/.vimrc has been the historical location for the user's vimrc for a very long time. We also had a separate directory for our plugins, colorschemes, etc.: $HOME/.vim. That's two "objects"...
romainl's user avatar
  • 41k
2 votes
Accepted

Why so % does not work when vimrc changes with another editor?

:so %, short for :source %, is: the :help :source command, which is used to "source" vimscript files, %, which is a shortcut for "the current file". Therefore, it means "...
romainl's user avatar
  • 41k
2 votes
Accepted

Calling variables from SHELL and using them in Vim config (vimrc)

To export a variable to child process I believe you should do: var="value" export var Remark if you do: export $var you will export the value variable. Once the variable is correctly ...
Vivian De Smedt's user avatar
2 votes
Accepted

Change what Vim does by default when no files are given

Here is the test used by Startify: fun! Start() " Don't run if: we have commandline arguments, we don't have an empty " buffer, if we've not invoked as vim or gvim, or if we'e start ...
Vivian De Smedt's user avatar
2 votes

Additional filetypes for different types of yaml files

Yes! This is called a « dotted filetype », and it has some subtlety but can be used for the mechanism you want: set filetype=yaml.kubernetes Then you can customize the kubernetes filetype. Beware of ...
D. Ben Knoble's user avatar
  • 26.4k
2 votes
Accepted

How to save the files when global replace completed in one command line

Yes. The problem is that global takes all the rest of its arguments as the command to execute on matching lines. But you can manipulate what it sees with execute: let i=1 | execute 'global/regexp/...
D. Ben Knoble's user avatar
  • 26.4k
2 votes

How can I extend syntax highlighting with my own keywords?

Your solution is already pretty close. However, there are three minor issues with it: The filetype for JavaScript is called "javascript", not "js". That's what your file is ...
Friedrich's user avatar
  • 2,033
2 votes

Clipboard Copy and paste remap

A major downside of Vim is that it is not as discoverable as your run-of-the-mill GUI editor, which makes it a lot less intuitive for the newcomer. A major upside of Vim is that it compensates the ...
romainl's user avatar
  • 41k
2 votes

Order of sourcing scripts

When you speak of mappings being overridden, and even of putting mappings either in the vimrc or in ftplugin files, I'm wondering something. I'll address this doubt, to be sure. Are the mappings you ...
Luc Hermitte's user avatar
  • 17.4k

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