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 ...
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 ...
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/...
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 ...
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.
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 ...
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! $"...
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 ...
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 ...
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/\...
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 ...
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 ...
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 *
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
vimscript × 1402vimrc × 233
key-bindings × 119
functions × 99
neovim × 92
regular-expression × 48
syntax-highlighting × 46
autocmd × 46
buffers × 40
search × 34
command-line × 30
visual-mode × 30
gvim × 29
vim-windows × 28
variables × 26
external-command × 24
plugin-system × 24
statusline × 24
cursor-movement × 20
register × 19
vimscript-python × 19
terminal × 18
autocompletion × 18
highlight × 18
indentation × 15