The problem:
-- Turn this..
M.nnoremap('gr',"<cmd>lua require('lspsaga.rename').rename()<CR>","rename var")
-- Too this effortlessly... ^^^^^^^^^^^
M.nnoremap('gr',"<cmd>lua require('lspsaga.rename').rename()<CR>","rename_var")
-- ^^^^^^^^^^^
Overview
Today I wanted to organize my init.lua and I got stuck on this.
I had a bunch of this remaps , and all i wanted to do was try out changing the space with an underscore.
- At first i thought of visually selecting it and then just running
s//on the selection. As i have previously seen that`<,`>is character wise selection( :h `< ), but it seems i was wrong. - Then I thought of using regex to substitute it but that is way to difficult for just this little trial of mine.
- I also remembered that Kakoune had a feature where you could pass text to GNU commands and return them. So i went ahead and tried searching for doing something similar in nvim. I found nothing. I knew that with
readand!i could get something similar but it was a bit hacky…
:read !echo "rename var" | tr " " "_"
I had toyi"then when writing the commandCtrl-Rto paste it and echoed it to my command.
It worked ok but it printed to new line
I searched the manuals but found nothing to help me put it in current line or in a register
Edit: I read manuals onfiltersand saw that you could apply it in a range or motion, i tried it but it seems that it does it line wise anw…
Trying to!i"in
NVIM v0.6.0-dev+274-g6188926e0
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/inferno/.cache/paru/clone/neovim-git/src/build/config -I/home/inferno/.cache/paru/clone/neovim-git/src/neovim-git/src -I/usr/include -I/home/inferno/.cache/paru/clone/neovim-git/src/build/src/nvim/auto -I/home/inferno/.cache/paru/clone/neovim-git/src/build/include
Compiled by inferno
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
results in a line wise edit…
- After all this i gave macros a try but with the number of spaces not being fixed
eg. ...show line diagnostics (3 spaces)i could make it work without spamming the macro manually.
I’ve been using nvim for almost a year now , which means a still don’t know much . Maybe some of you are gonna say “What?? you only have to do this and this…” which i will be happy to hear cause i love to learn more stuff about nvim, and was mainly the purpose of this post.
Is there a plugin to help with these kind of tasks? …Maybe multiple cursors could solve my problem?
it would be nice to try implementing GNU commands more in to nvim through a plugin or natively through nvim APIs. I’ve never made an nvim plugin but i think expanding on these while learning to make a plugin would be fun!
