2 votes
Accepted

How can I use `:keepjump` with `gd`/`gf`/searches?

Try this: nnoremap gd m':keepjumps normal!gd$Bgf<CR>:noh<CR> :keepjumps allows you to perform command-line commands without changing the jumplist, but your mapping uses normal-mode ...
user avatar
  • 28.3k
2 votes

How to check if the last executed command was *this* function?

An interesting idea! The problem It's not really possible to implement your mapping in the way you suggest. Vim only stores the last executed command internally (for use with the dot command), and ...
user avatar
  • 28.3k
2 votes
Accepted

Certain commands in vimrc not being picked up anymore

After some discussion in the comments, it turns out that the vimrc file you were editing was the ~/.vim/vimrc file. But the ~/.vimrc file takes priority when it exists. So Vim was ignoring your ~/.vim/...
user avatar
  • 26.3k
2 votes

After copying a visual selection, return to original location

vim solution : source You can just copy the paragraph to the clipboard with "+yip Instead of selecting the paragraph and copying it just set an auto command with the TextYankPost event. In vim, I ...
user avatar
  • 1,017
1 vote
Accepted

How to enforce a specific order for the windows opened by diffsplit?

:h 'splitbelow' :h 'splitright' If you add set splitbelow splitright To your vimrc, it would be the opposite to default behavior. Note, it would affect all your splits, not only diffsplit.
user avatar
  • 10.4k
1 vote
Accepted

How to change editor options when switching to diff mode?

In the solution you have tried the OptionSet triggers the autocmd that are linked to VimEnter But it is too late. The VimEnter event has already been triggered and it doesn't work. But for OptionSet ...
user avatar
1 vote

How to check if the last executed command was *this* function?

Ok, since I was unable to compare the keycode I get (^[[4~) with what getchar() returns, I came up with another solution: function! Jumptails() let l:colat = col('.') execute "normal! $"...
user avatar
  • 33
1 vote

How to remove underscore and capitalize the next character in the first word?

Another :substitute-based option, where the pattern is simpler: :substitute/\v_(\a)/\u\1 and then use & to repeat this on the line until you are satisfied (it only changes the first _ in the line ...
user avatar
  • 21.5k
1 vote
Accepted

How to remove underscore and capitalize the next character in the first word?

You could try substitute with :h sub-replace-special: :%s/^\w\+/\=substitute(submatch(0), '_\(\a\)', '\u\1', 'g') with :%s/^\w\+/ you target first word, then with special replace, you substitute ...
user avatar
  • 10.4k
1 vote

How can I use `:keepjump` with `gd`/`gf`/searches?

Save cursor position into :h 'quote mark. For example, ~/.vim/after/ftplugin/javascript.vim nnoremap <buffer>gd <cmd>let w:curpos = getcurpos()[1:]->insert(bufnr())<CR> \gd/\...
user avatar
  • 17k
1 vote

Automatically highlight visual selection matches

I have made it work. Firstly, I found from Vim does not call functions correctly when wrapped in another function that "Vim doesn't like updating Screen too often" so redraw was necessary ...
user avatar
  • 21
1 vote

Solving issue with clang-format-vim.py saving new buffer

I don't know why the ClangFormat documentation recommends that approach, but it just makes things difficult. You just need to set formatprg in ~/.vim/after/ftplugin/cpp.vim as follows: setlocal ...
user avatar
  • 412
1 vote

Keep cursor from moving when using operators

I would suggest you this solution pure vim solution: augroup yank_restore_cursor autocmd! autocmd VimEnter,CursorMoved * \ let s:cursor = getpos('.') autocmd TextYankPost * ...
user avatar
  • 1,017

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