Unfortunately nnoremap ab gd:
doesn't work on my machine.
When I hit ab
, the gd:
remap selects the words under the cursor as gd
(or gD
) should do but it doesn't enter into command mode after as :
usually does. If I type the sequence gd:
orgD:
directly in neovim, it works fine and enters into command mode after selecting the words under the cursor.
When I replace gd
with gg
, nnoremap ab gg:
works fine. It moves to the beginning and enters command mode. Any ideas why gg:
works while gd:
doesn't?
My goal is to make a map such as:
nnoremap gR gD:%s/<C-R>///gc<left><left><left>
for global search and replace
I am using:
$ vim --version
NVIM v0.2.2
Build type: RelWithDebInfo
LuaJIT 2.0.4
Compilation: /usr/bin/x86_64-linux-gnu-gcc -g -O2 -fPIE -fstack-protector- strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-HJnLxJ/neovim-0.2.2/build/config -I/build/neovim-HJnLxJ/neovim-0.2.2/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/build/neovim-HJnLxJ/neovim-0.2.2/build/src/nvim/auto -I/build/neovim-HJnLxJ/neovim-0.2.2/build/include
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
My full plugin free ~/.config/nvim/init.vim
looks like this (where ab
doesn't work and ba
does work):
set guicursor=
nnoremap ab gD:
nnoremap ba gg:
Update
nnoremap ab gD:
gD
means 'go to definition'. This fails when this command is executed at the defintion itself. It works only when:
the selected word is not the first occurence.
A simple workaround is to use a search with *
instead of 'go to definition'
nnoremap ab *:
. search and replace would then be:
nnoremap gR *:%s/<C-R>///gc<left><left><left>