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

How to save the original candidate lines ? #1273

Closed
mario206 opened this issue Nov 4, 2017 · 5 comments
Closed

How to save the original candidate lines ? #1273

mario206 opened this issue Nov 4, 2017 · 5 comments

Comments

@mario206
Copy link

mario206 commented Nov 4, 2017

Given the following buffer

line1
line2
????
line3

input line,and then press C-c C-o result in

3 candidates:
./*scratch*:1:line1
./*scratch*:2:line2
./*scratch*:3:line3

What if I just want to save the original lines ?

line1
line2
line3

It's very useful when I have to search several things and finally merge them together to analyze a log file。
Is there a solution?

@abo-abo abo-abo closed this as completed in 301139d Nov 4, 2017
@abo-abo
Copy link
Owner

abo-abo commented Nov 4, 2017

Here are the steps:

  1. R to disable read-only-mode.
  2. swiper with input .*:.
  3. M-< to make sure the first line you want is selected.
  4. M-q to start quary-replace
  5. RET to enter "nothing" as replacement.
  6. ! to replace all at once, instead of y/n on each item.

For a more complex buffer content, you can adjust the regex to ^.*[0-9]:.

@mario206
Copy link
Author

mario206 commented Nov 4, 2017

Thanks for your reply.
But is there anything wrong with my operation?
error tips "Buffer is read-only"
Here's a gif

And is there a faster way to do so without taking 6 steps?
Can we just press something like c-c c-p to make all things done?

@abo-abo
Copy link
Owner

abo-abo commented Nov 5, 2017

error tips "Buffer is read-only"

You need to upgrade to the latest version of the package. The binding R to disable read-only mode was created only 22 hours ago in my reply to your issue.

And is there a faster way to do so without taking 6 steps?
Can we just press something like c-c c-p to make all things done?

It's actually only two steps:

  • disable read only mode
  • query replace ".*:" with "" using swiper

Both of these actions are highly reusable and applicable in many situations. Composing them together makes an function that's less reusable (and less discoverable, since not everyone knows it's bound to C-c C-p).

I'll see if it's a good idea for swiper's query-replace to disable read-only mode automatically; even less steps.

@abo-abo
Copy link
Owner

abo-abo commented Nov 5, 2017

OK, after the update it's one step:

C-s .*: M-q RET !

@mario206
Copy link
Author

mario206 commented Nov 6, 2017

It works!
Thanks for your time.
I will try using macro to make it less keystrike.

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