8
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-...
8
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 ...
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 ...
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 ...
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 ...
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 / ...
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 ...
1
vote
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
...
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 =~# '...
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 ...
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)
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
events × 11autocmd × 9
vim-windows × 2
pattern × 2
vimscript × 1
key-bindings × 1
neovim × 1
command-line × 1
buffers × 1
visual-mode × 1
terminal-buffer × 1
line-numbers × 1
lua × 1
command-line-window × 1
cmdline × 1