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

pipe command: add a way to optionaly disable appending a newline to selections #1515

Closed
Delapouite opened this issue Jul 20, 2017 · 1 comment

Comments

@Delapouite
Copy link
Contributor

Delapouite commented Jul 20, 2017

Hi

This is somehow related to #1216 where mawww explains the rational behind the fact that | always add a newline to selections.

I was not really aware of this before being confronted to the following situation and found this behavior surprising.

Here's my input text:

accessibility
electrolysis
internationalization
localization

Then %<a-s>HH<a-;>L, which create the following selections:

a[ccessibilit]y
e[lectrolysi]s
i[nternationalizatio]n
l[ocalizatio]n

Which I pipe | through wc -c. It produces:

a12y
e11s
i19n
l11n

Which is wrong (well in the sense of what I tried to achieve). It forces to pipe to tr -d '\n' | wc -c instead to get the expected result:

a11y
e10s
i18n
l10n

What's your take on this?

Did you encounter this behavior in other scenarios? Should this deserve another dedicated pipe-without-newline primitive?

@lenormf
Copy link
Contributor

lenormf commented Jul 22, 2017

This is a tricky case, because we have to make assumptions that simplify the user's life whenever using |/<a-|>. On one hand we assume that the command is a filter, so we add a newline character to the selection so that the user doesn't have to do it manually, but on the other hand sometimes the user wants to pipe the selection and only that (i.e. your exact case), which forces them to modify the command (and even that won't be reliable in all cases, unfortunately).

Going one way or another will be an inconvenience to both side as they hit one case or the other, and adding new primitives doesn't sound too good.

What about creating a special register that would contain flags that activate or deactivate side effects on some commands?

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

No branches or pull requests

2 participants