New answers tagged

3

Use a :terminal: " in ~/.vim/after/ftplugin/python.vim nnoremap <buffer> <CR> :write <bar> terminal python3 %<CR> " update b:undo_ftplugin When the command is finished, you can :set modifiable (:set ma) and edit.


2

In the end I managed to do this by checking the number of modified buffers. Once the number of buffers reaches 0, only then run rsync. func! CountModifiedBuffer() " See https://vi.stackexchange.com/a/14313/40380 return len(filter(getbufinfo(), 'v:val.changed == 1')) endfunc augroup project autocmd! autocmd BufWritePost path/to/project/* ...


1

You may run autocmd FileType python map <buffer> <CR> :w<CR>:call Exec('!python3 '.expand('%'))<CR> And use: function! Exec(cmd) redir @x exec printf('silent %s',a:cmd) redir END tabnew norm "xp endfunction It writes the output of a command in a new tab.


2

This difference is pretty obvious: BufEnter X: It was bufnr() != X But now it becomes bufnr() == X BufWinEnter X: It was len(win_findbuf(X)) == 0 But now it becomes len(win_findbuf(X)) == 1


1

I ended up combining bits of solutions provided by Luc and Maxim, ending up with the following in my .vimrc: " clear all mappings starting with space in insert mode " based on https://vi.stackexchange.com/a/26385/40274 " and https://vi.stackexchange.com/a/26384/40274 function! ClearInsertLeaders() abort let s:mappings = execute('imap &...


3

Is this possible using QuitPre? "Quit" means quitting a buffer as in :quit. You probably want ExitPre instead. can I implement such functionality using Vimscript? No, AFAIK, the action cannot be aborted by autocmd. Based on the user's response, Vim should either quit, or cancel the quit Simply :set confirm and no worries.


1

vim-polyglot has addressed this issue. In commit Use setf for ambiguous extensions from Aug 24, 2020, it started converting from set filetype=... to the setf command, then later commit Make loading faster for ambiguous extensions without heuristics from Sep 29, 2020 expanded the use of setf to other extensions such as .template for filetype json. This makes ...


Top 50 recent answers are included