New answers tagged

0 votes

How to enforce settings on debian Vim?

In short: put let g:skip_defaults_vim = 1 in /etc/vim/vimrc.local . Ben Knobles answer helped a lot to understand, what is going on. Finally I wanted to report a bug to the debian, but it had been a ...
peterh's user avatar
  • 1,149
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
0 votes

Setting variables in file in ftplugin directory

Filetype plugins, whether they are from $VIMRUNTIME/ftplugin, ~/.vim/ftplugin, or ~/.vim/after/ftplugin, are sourced before any syntax script. The "options" you listed in your question are ...
romainl's user avatar
  • 40.6k
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
3 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
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,877
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

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.6k
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
0 votes

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

Hold Shift, then copy like in terminal (select text with mouse, press Ctrl + Shit + C) Related question: linux - How do I copy command output in vim? - Super User
Anton Samokat's user avatar
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
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
0 votes
Accepted

if endif oneliner failure in VIM

The issue is within echo(w) as it can't figure out where is the end of the command. A workaround is to wrap it with execute: if v:false | exe 'echow "g:mode_class "' | else | exe 'echo "...
Maxim Kim's user avatar
  • 13.4k
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
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
0 votes

How to jump to the last non-blank character in soft wrapped long line in vim?

Since Vim patch v9.0.1753 you can now use g<end> to jump to the last non-blank char on a line.
Christian Brabandt's user avatar
1 vote

Using the return of a user defined function in an :execute statement

I'd use CTRL-R= directly here. Also, it seems like you're trying to emulate expand('%:p:h') nnoremap <silent> <F5> :<c-u>!echo <c-r>=expand('%:p:h')<cr><cr> (I'm ...
Luc Hermitte's user avatar
  • 17.4k
1 vote
Accepted

mapping works on next line instead of current

The problem is caused by the extraneous space between <Esc> and :: inoremap <C-f> <Esc> : exec '.!printf "world"'<CR> ^ The right-hand side of a ...
romainl's user avatar
  • 40.6k

Top 50 recent answers are included