Editing Commands
All edit commands read the new code from stdin. This makes them composable with code generators, formatters, or other tools.
edit replace
Section titled “edit replace”Replace a symbol’s entire body.
cat new_impl.rs | krait edit replace <symbol>Example:
cat updated_service.ts | krait edit replace OrderServiceThe LSP locates the symbol’s exact start and end, including its closing brace. The new code from stdin replaces everything in between.
edit insert-after
Section titled “edit insert-after”Insert code after a symbol’s closing brace.
echo 'fn helper() {}' | krait edit insert-after <symbol>edit insert-before
Section titled “edit insert-before”Insert code before a symbol’s declaration.
echo '#[derive(Debug)]' | krait edit insert-before MyStructrename
Section titled “rename”Cross-file rename using LSP workspace/rename. Updates all references automatically.
krait rename <old-name> <new-name>Apply LSP quick fixes to a file.
krait fix [path]format
Section titled “format”Run the LSP formatter on a file.
krait format <path>Stdin Patterns
Section titled “Stdin Patterns”# From a filecat new_body.rs | krait edit replace MyStruct
# From a heredockrait edit replace MyStruct << 'EOF'pub struct MyStruct { name: String,}EOF
# From a commandgenerate-code --symbol MyStruct | krait edit replace MyStructTip: Avoid
echofor multi-line content — use heredoc or pipe from a file.