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
2 votes

How to split terminal and start in the other buffer?

I would try command! Tright vert rightb terminal zsh And then: $ vi <file> -c "Tright" -c "normal <C-W>h"
Vivian De Smedt's user avatar
2 votes
Accepted

How to enforce settings on debian Vim?

Copying my comment here: Couple tips: use :verbose set opt? and :verbose setlocal opt? to find out where opt was last set. And, unless you need system-wide configuration, try a user vimrc (e.g., ~/....
D. Ben Knoble's user avatar
  • 26.2k
1 vote

Setting variables in file in ftplugin directory

Filetype plugins are meant to set buffer local stuff. All your variables are global. IMO, It doesn't make sense to set, and reset, and reset them again and again every time you open a new C file. Even ...
Luc Hermitte's user avatar
  • 17.4k
1 vote
Accepted

Setting variables in file in ftplugin directory

The ftplugin intention is to replace the autocmd FileType calls. The corresponding file is executed after the filetype is set and before the corresponding distribution file is executed. It is not too ...
Vivian De Smedt's user avatar
1 vote
Accepted

How to split terminal and start in the other buffer?

Plain: vim filename -c "vert rightb term zsh" -c "wincmd h" With additional command in vimrc: command! VT exe "vert rightb term zsh" | wincmd p $ vim filename -c VT
Maxim Kim's user avatar
  • 13.4k
1 vote
Accepted

How do I prevent/remove/delete temp files?

The files you see are the backup file quotes.txt~ and the undo file .quotes.txt.un~. Turn them off You can prevent these files from being created by adding the following lines to your vimrc: set ...
Friedrich's user avatar
  • 1,912
1 vote
Accepted

Renumbering in Vim: g<C-A> won't work in vimscript function

To renumber till the end of the buffer I would do: :normal! VGg^A Where ^A is inserted using Ctrl va Or :execute "normal! VGg\<C-a>" If you want to trigger it from an existing ...
Vivian De Smedt's user avatar
1 vote
Accepted

How to copy text to clipboard from status bar (statusline) in Vim

You can't copy because set mouse=a gives Vim full control of the mouse. Since this is vi.stackexchange.com, a proper Vim solution would simply be to: disable mouse handling with :set mouse=, select ...
romainl's user avatar
  • 40.7k
1 vote

Why does ":normal gv" keep removing one line from my visual block?

The call :'<,'>call F() (which you get from visual mode) runs F on each line unless F has range. So you’re invoking normal gv on each line. I can’t explain the result you got, but that seems ...
D. Ben Knoble's user avatar
  • 26.2k
1 vote
Accepted

Why does ":normal gv" keep removing one line from my visual block?

:normal gv in visual mode becomes :'<,'>normal gv which runs it for every line in selection. Now why it ends up with a selection 1 line less, I am not sure about, but I think it is related to gv ...
Maxim Kim's user avatar
  • 13.4k

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