flemingfleming
  • Member for 3 years, 10 months
  • Last seen more than 3 years ago
VIM swap-file best practices?
Accepted answer
35 votes

Don't Panic! Recovering files is always safe, because vim never writes any changes until you write them yourself. So recovering from a swap file and then closing without saving won't change anything. ...

View answer
copy line XX and paste it below my cursor (avy / ace jump style)
Accepted answer
5 votes

I mean 21ggyy''p is pretty fast, but here's a simple ex command: :21t. Act on line 21 t for copy ( :copy also works here) . Is special for the current line. (:h :t) You can also supply relative ...

View answer
Wrapping lines in a paragraph with header and footer lines
Accepted answer
5 votes

The classic :s command can do stuff like this easily. e.g. type :s/.*/:start\r&\r:end\r/ It looks like :'<,'>s/.*/:start\r&\r:end\r/ on the command line if you select the area first, ...

View answer
How to do a find with a regex and jump to a specific position within the match
Accepted answer
5 votes

You can use \zs (and it's complement, \ze), e.g. /:q: \zs should work for your example (assuming there is exactly 1 space after the second :) It works by setting the start (or end in the case of \...

View answer
How to undo the deletion of characters in insert mode caused by Ctrl-U?
Accepted answer
3 votes

You can't recover the words you've already lost, but we can make <c-u> an undo-able motion by remapping it: inoremap <c-u> <c-g>u<c-u> This is from vim-sensible. See :h ...

View answer
<S-BS> and <C-BS> mappings not working
Accepted answer
3 votes

In general this isn't possible, or will have strange side effects due to the way special keys are handled, but it depends on exactly what your terminal emulator is sending. You can find out the keys ...

View answer
Vim on Debian, configuration issues
Accepted answer
3 votes

/usr/share/vim/vimrc is always sourced regardless of your vimrc (assuming $VIM doesn't point somewhere else - :h system-vimrc). The settings you're probably missing are in defaults.vim, a file that ...

View answer
Open quickfix window without focusing it
2 votes

Running wincmd p after the copen should work; you jump to the quickfix window and then right back to the window you were in e.g. autocmd QuickFixCmdPost * botright copen 8 | wincmd p see :h wincmd, :...

View answer
BufNewFile doesn't work from ftplugin
Accepted answer
2 votes

Problem was already diagnosed in the comments, and your current solution won't work if you try to start editing a file from within vim. If that's a problem, try this: " This goes directly in ~/.vim/...

View answer
Is loadview conflicted with readonly mode?
Accepted answer
2 votes

By default, :mkview saves the state of the 'readonly' option. This means if you previously closed the file when it wasn't read only, then when you reopen it, :loadview sets :set noreadonly and changes ...

View answer
Convert a search and replace to a function
Accepted answer
2 votes

The simplest way of doing what you want is probably not to use a function, but instead use a command: command! -range MySubCmd <line1>,<line2>s/\v.{-}(`.{-}`).{-}(\\'.{-}\\').*/$this->...

View answer
How to use pure Vim as git mergetool?
Accepted answer
2 votes

I think something like this in your ~/.gitconfig file should do what your asking. [merge] tool = myvimdiff [mergetool "myvimdiff"] cmd = vim "$MERGED" There are lots of other options for ...

View answer
How to match for diacritic combinations
2 votes

It depends on exactly how careful you want to be with your matches, but there are many options. The simplest would be to just replace \l with \U (any non-uppercase character): /\u\U\U Unfortunately ...

View answer
Strange behaviour of autocmd
Accepted answer
2 votes

The culprit appears to be the WinEnter autocmd, which is apparently being triggered with the buffer you left and not the one you entered. To demonstrate, you can set up an autocmd like this to print ...

View answer
How can I automatically preform operations when a vim *window* is resized?
1 votes

Currently, there's no autocommand for this (although it would be very useful). A possible way to do this is to poll vim every CursorHold event, and check to see if the window size has changed; the ...

View answer
Applying vimrc to vimtutor in Windows
Accepted answer
1 votes

Simple answer, yes, all you need to do is run the :so[urce] command from within vimtutor: :source ~/_vimrc (change the path to wherever your vimrc is located. Inside vim you can always use forward ...

View answer
Neovim on Manjaro- No ~/.config/nvim file being created on install
Accepted answer
0 votes

In short, yes. Just create ~/.config/nvim/init.vim and neovim will find it. Nothing magic happens; neovim simply looks for an init.vim file at that location. (You can check all the files installed by ...

View answer