I'm working a function to rename the visual selected text
function! Rename()
name = getline("'<")[getpos("'<")[2]-1:getpos("'>")[2]-1]
let newname = input('rename the selection with: ')
execute ":%s/\\<".name."\\>/".newname."/g"
endfunction
Is it possible to have the content of name
as the the default value of the input()
function? To be more specific, I'd like to have the command line become (take name
content to be ibasis
for example)
rename the selection with: ibasis
when I call this function. I can then use my mapping <C-a>
to go to the start of ibasis
, delete i
and quickly get the desired result of replacing ibasis
with basis
.