Skip to main content
10 votes
Accepted

How do you manually trigger an event?

What you are looking for is :doautocmd. With this you can trigger all the autocmds in an event, or just those that match a specific pattern. Or you can scope based on autocmd group. For example, to ...
Heptite's user avatar
  • 1,086
9 votes
Accepted

Detecting the Enter and Leave of Visual mode event

September of last year, a new event was added: commit f1e8876fa2359b572d262772747405d3616db670 (tag: v8.2.3430) Author: =?UTF-8?q?Magnus=20Gro=C3=9F?= <[email protected]> Date: 2021-...
3N4N's user avatar
  • 5,824
3 votes
Accepted

Is there going to be a VimConf this year?

The official VimConf has been canceled in 2020: We have decided to cancel VimConf 2020 due to the changes in the social situation caused by COVID-19 (SARS-CoV-2, a new type of coronavirus). We also ...
filbranden's user avatar
  • 29.1k
2 votes
Accepted

What is the pattern matched against for events CmdwinLeave and CmdwinEnter?

Those things are easy to test with :help <amatch>: autocmd! CmdWinLeave * echomsg expand('<amatch>') Where you use a wildcard to catch every possible case and echo <amatch> in the ...
romainl's user avatar
  • 41.4k
2 votes
Accepted

What is the reason to not have <C-c> trigger InsertLeave event?

I'm not sure if you're going to like this answer because it's a bit circular, but it's so you can leave Insert mode without triggering InsertLeave or abbreviations! Traditionally Ctrl-C is used for ...
Rich's user avatar
  • 32.3k
2 votes

Misunderstanding of interaction between local options, moving between windows, and WinLeave, WinEnter, BufLeave, BufEnter events

When Vim opens help page it does the following: Split current Switch to new help buffer Follow the tag And so, Why do the first time I do :h and the second time generate different output? For the ...
Matt's user avatar
  • 21k
2 votes
Accepted

How to close Terminal and NERDTree windows if they are the last windows?

Here is a more sophisticated solution. It try to close Vim if the only visible windows are 'side bars' (buffer that don't contains 'real' document) like: Terminal QuickFix window LocationList window ...
Vivian De Smedt's user avatar
2 votes

How to close Terminal and NERDTree windows if they are the last windows?

I would do: autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && &buftype ==# 'terminal' | bd! | q | endif Compare to the NerdTree solution we do: Check that the last ...
Vivian De Smedt's user avatar
2 votes
Accepted

Is it correct that between a CmdlineLeave and a CmdwinEnter there must be a CmdlineEnter?

This is an implementation detail and it is not documented anywhere. Hence, it is absolutely NEITHER SAFE NOR RECOMMENDED to rely on this behaviour. But, yes, q/ (and similar) is internally mapped to / ...
Matt's user avatar
  • 21k
1 vote

How can I deactivate CR only if its effect is to move to the next line?

Using an expression mapping is probably the easiest here: :nnoremap <expr> <CR> &ft == 'qf' \|\| getcmdwintype() != '' ? '<CR>' : '' If the filetype is qf or getcmdwintype() is ...
Martin Tournoij's user avatar
1 vote

What is the pattern matched against for events CmdwinLeave and CmdwinEnter?

The documentation makes this clear I believe: :h CmdwinLeave mentions this: <afile> is set to a single character, indicating the type of command-line. |cmdwin-char| (same for :h CmdwinEnter) ...
Christian Brabandt's user avatar
1 vote

How can I execute a command after searching with `/`?

I believe the "classic" solution remaps various search keys: " If you have other <Enter> mappings, you might want `:nmap` here :cnoremap <expr> <Enter> getcmdtype =~# '...
D. Ben Knoble's user avatar
  • 26.8k
1 vote

How to detect split window resized?

It exists since Vim 9.0.0917 Patch 9.0.0917 Problem: The WinScrolled autocommand event is not enough. Solution: Add WinResized and provide information about what changed. (closes #...
Luc Hermitte's user avatar
  • 17.6k

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