Skip to content
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

commands: Replace all characters in selection, make r<ENTER> work #167

Merged
merged 5 commits into from
Jun 8, 2021

Conversation

vv9k
Copy link
Contributor

@vv9k vv9k commented Jun 7, 2021

Closes: #161
Closes: #164

helix-term/src/commands.rs Outdated Show resolved Hide resolved
@vv9k
Copy link
Contributor Author

vv9k commented Jun 7, 2021

I pushed some changes, previously r would place all the replaced characters on one line as no new line characters were added. Now it properly replaces all characters but newlines in selection. Is this behaviour correct or should I further adjust it?

@vv9k vv9k force-pushed the replace branch 2 times, most recently from c67f809 to b90ef9c Compare June 7, 2021 19:40
@archseer
Copy link
Member

archseer commented Jun 8, 2021

Good question, kakoune seems to replace newlines too but maybe we can change the behavior here.

\cc @CBenoit @pickfire any thoughts on this?

helix-term/src/commands.rs Outdated Show resolved Hide resolved
@pickfire
Copy link
Contributor

pickfire commented Jun 8, 2021

I never had to replace across lines so I don't have hard opinion on this.

@CBenoit
Copy link
Member

CBenoit commented Jun 8, 2021

To be honest, my main use for replace is when I want to change one specific character, so I'm not completely sure. If anything, I think ignoring newlines plays better with line-wise selections. For example in kakoune if I want to change all characters on one line, I select with x and then replace with r{char}. However, x will select the newline character that will then get replaced and gives us an additional (and probably unwanted) {char}.

Replacing a newline could be useful to change it for a space (or something else) effectively giving us a join operation, but we already have a join command better suited for that.

TL;DR: I'm rather in favor of ignoring the newlines.

By the way, (neo)vim also ignores newlines.

Worst case, we can change the behavior again later.

@vv9k
Copy link
Contributor Author

vv9k commented Jun 8, 2021

That is also what made me add this changes, I noticed that when I select a whole line and replace it with something the newline character also gets replaced and the next line is appended to the previously selected line.

@vv9k vv9k changed the title commands: Replace all characters in selection commands: Replace all characters in selection, make r<ENTER> work Jun 8, 2021
@archseer archseer merged commit 4e3a343 into helix-editor:master Jun 8, 2021
@vv9k vv9k deleted the replace branch June 9, 2021 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

r<Enter> should work r should replace every character in the selection
4 participants