Rename
Usage #
Run :Lspsaga rename
. Other than opening the float input window it will also highlight the references in this buffer.
Default Options #
Default options in rename
section:
in_select = true
- Default is
true
. Whether the name is selected when the float opens - In some situation, just like want to change one or less characters,
in_select
is not so useful. You can tell the Lspsaga to start in normal mode using an extra argument like:Lspsaga lsp_rename mode=n
- Default is
auto_save = false
- Auto save file when the rename is done
project_max_width = 0.5
- Width for the
project_replace
float window
- Width for the
project_max_height = 0.5
- Height for the
project_replace
float window
- Height for the
Default Keymaps #
Default keymap in rename.keys
section:
quit = '<C-k>'
quit rename window orproject_replace
windowexec = '<CR>'
execute rename inrename
window or execute replace inproject_replace
windowselect = 'x'
select or cancel select item inproject_replace
float window
Project-wide Replace #
LSP rename can only rename language symbols. Lspsaga provide async project level search and replace by using rg
,
so make sure it’s installed if you want to use this feature.
Run :Lspsaga project_replace old_name new_name
. It will search the whole project to find old_name
and show if in a float window.
- use
rename.keys.select
to select item to rename - use
rename.keys.exec
to executenew_name
replace
LSP Integration #
Use ++project
flag for the lsp_rename
command (:Lspsaga lsp_rename ++project
)
After the LSP rename is done, and if the name still exists somewhere within the project, the project_replace
window would pop out.