-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement inccommand
#7416
Implement inccommand
#7416
Conversation
- Add new config key vim.inccommand which can take values "", "append", or "replace" - Add config keys vim.substitutionColor and vim.substitutionTextColor - Add new abstract method getDecorations to CommandLine class - Move logic for computing search highlights from updateSearchHighlights method of modeHandler to getDecorations method of SearchCommandLine - Add closed field to Pattern class to keep track of whether the pattern was input with a closing delimiter - In substitute.ts, separate argument resolution from command execution, and add new method to compute substitution decorations.
When executing an :s command with the c flag: - Highlight current match with searchMatch, other matches with searchMatchHighlight - Simulate incremental replacements by concealing confirmed substitutions with decorations Move decoration utilities to their own file
When executing an :s command with the c flag: - Highlight current match with searchMatch, other matches with searchMatchHighlight - Simulate incremental replacements by concealing confirmed substitutions with decorations Move decoration utilities to their own file
Co-authored-by: Jason Fields <[email protected]>
I'm not super familiar with github actions, but is this check working as intended? The only changes were to the README, and things seem to be going wrong when it's reformatted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
My pleasure! |
I have been using this plugin for quite sometime, and didn't realise this feature had landed until I saw the preview when using the replace command. Just came to say thank you. 🙏 😊 🤩 |
What this PR does / why we need it:
This PR introduces the option
inccommand
, which enables a live preview of:s
commands as they are typed. It also makes some improvements to interactive substitution with thec
flag.The feature is configured by setting
vim.inccommand
to'append'
or'replace'
(or''
to disable).When set to
'append'
, substitution previews are inserted after each highlighted match, a behavior found in some popular vim emulators like spacemacs.When set to
'replace'
, the substitution previews replace each match, which is consistent with the default behavior of neovim.The config keys
vim.substitutionColor
andvim.substitutionTextColor
are provided to control the appearance of preview text.Which issue(s) this PR fixes
#6656
Also addresses #6655
Special notes for your reviewer:
Probably the biggest change from the original neovim behavior is how multi-line substitutions are handled. Since decorations can't change the apparent number of lines in the editor, concealed multi-line matches still have line breaks that won't be present once the substitution is performed. Multi-line replacements also have to be displayed inline; I currently do this by replacing line breaks with the character
⏎
(U+23CE, "RETURN SYMBOL"), but it might be more sensible to use standard escape sequences.