Skip to content
/
Try

Refactoring in Skink: rename, move, extract, safe delete

Rename across files through the refactor preview.

Press Alt+Shift+R to rename the symbol at the cursor everywhere. Any change that touches several files opens the refactor preview first, so you check it before anything is applied.

Other refactors are commands:

  • :mv moves a file and updates its imports.
  • :extract var or :extract fn pulls out the selection.
  • :safedelete removes a declaration nobody uses.

Most of these use your language server. See Code intelligence for setup.

The preview lists the files and hunks a change will touch, each with a checkbox, and a side-by-side diff of the selected one.

Key Does
↑ / ↓ Move between files and hunks
Space Check or uncheck
a Check all
n Check none
Enter Apply the checked changes
Esc Cancel

Applying is one undo step per file. The changed files are left unsaved, so you get a last look and save them yourself.

The same preview is used for:

  • rename and multi-file code actions
  • file moves
  • project-wide replace (:greprep) and structural rewrite (:srep)
  • edits from AI agents

Alt+Shift+R asks for the new name. Or give it straight away:

:renamesymbol new_name
:rn new_name

The language server finds every real use, across files, so unrelated names that happen to match are left alone.

:mv src/util/strings.rs

This moves or renames the current file, relative to the project root. Open tabs follow the file.

Running language servers are asked first (workspace/willRenameFiles). The import and module-path changes they suggest open in the preview.

Renaming in the file tree (r or F2 on a file) does the same. New folders in the path are created for you.

Select an expression or some lines, then run one of:

:extract var [NAME]
:extract fn [NAME]

This uses the language server’s extract code action. extract var also works without a server for Rust, TypeScript/JavaScript and Python.

Put the cursor on a function, struct or class and run :safedelete. Skink runs find-references first:

  • No uses outside the declaration: the declaration, with its doc comments and attributes, is removed through the preview.
  • Uses found: they are listed instead, so you can deal with them first.

:safedelete! skips the check and opens the deletion in the preview unchecked, for you to decide.

Alt+Enter (or :fix) shows the server’s quick fixes and refactorings for the cursor position, such as “add missing import” or “inline variable”.

A lightbulb in the sign column means some are available. Ones that touch several files open the preview.

For changes by shape rather than by name, use ast-grep patterns:

:sgrep foo($A, $$$REST)
:srep foo($A, $B) => bar($B, $A)

:srep rewrites every match through the preview. See Project search.

Key Typed command Does
Alt+O / Alt+I :expand / :contract Grow / shrink the selection to the enclosing syntax node
Alt+↑ / Alt+↓ :moveup / :movedown Move lines
Ctrl+D :addcursor Multiple cursors on the next match (more)
:SortLines, :JoinLines Sort or join the selected lines
:UpperCase, :LowerCase, :TitleCase Change case of the selection or word

Every key also has a typed command. See Typed commands.