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

[Feature request] Insert word at point with C-w #125

Closed
sewkokot opened this Issue Jun 1, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@sewkokot

sewkokot commented Jun 1, 2015

I'm used to pressing C-w in isearch-forward to insert word-at-point in the minibuffer. Would it be possible to do it with swiper?

@abo-abo abo-abo closed this in 52a083e Jun 1, 2015

@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Jun 1, 2015

Owner

You have to bind it yourself as:

(define-key ivy-minibuffer-map (kbd "C-w") 'ivy-yank-word)

I prefer to have C-w call kill-region, as it does in other buffers. Also try C-s M-n - the preferred method to search for thing-at-point.

Owner

abo-abo commented Jun 1, 2015

You have to bind it yourself as:

(define-key ivy-minibuffer-map (kbd "C-w") 'ivy-yank-word)

I prefer to have C-w call kill-region, as it does in other buffers. Also try C-s M-n - the preferred method to search for thing-at-point.

@sewkokot

This comment has been minimized.

Show comment
Hide comment
@sewkokot

sewkokot Jun 1, 2015

Thank you for prompt response and implementation! Exactly what I wanted :)

sewkokot commented Jun 1, 2015

Thank you for prompt response and implementation! Exactly what I wanted :)

@sewkokot

This comment has been minimized.

Show comment
Hide comment
@sewkokot

sewkokot Jun 1, 2015

My first tests were when I had point at the bol but then when the cursor is further the function ivy-yank-word yanks string from the beg of line to the point. I modified your function a bit to suit my need.

  (defun my-ivy-yank-word ()
    (interactive)
    (let (amend)
      (with-selected-window (ivy-state-window ivy-last)
        (goto-char swiper--opoint)
        (setq amend (thing-at-point 'symbol)))
      (when amend (insert amend))))
  (bind-key "C-w" 'my-ivy-yank-word ivy-minibuffer-map))

sewkokot commented Jun 1, 2015

My first tests were when I had point at the bol but then when the cursor is further the function ivy-yank-word yanks string from the beg of line to the point. I modified your function a bit to suit my need.

  (defun my-ivy-yank-word ()
    (interactive)
    (let (amend)
      (with-selected-window (ivy-state-window ivy-last)
        (goto-char swiper--opoint)
        (setq amend (thing-at-point 'symbol)))
      (when amend (insert amend))))
  (bind-key "C-w" 'my-ivy-yank-word ivy-minibuffer-map))

abo-abo added a commit that referenced this issue Jun 1, 2015

Swiper should preserve column for empty input
swiper.el (swiper--update-input-ivy): When there's no input yet, don't
move point.

Re #125
@abo-abo

This comment has been minimized.

Show comment
Hide comment
@abo-abo

abo-abo Jun 1, 2015

Owner

My first tests were when I had point at the bol but then when the cursor is further the function ivy-yank-word yanks string from the beg of line to the point

Thanks for pointing that out, swiper should work better now. Your approach isn't optimal since it isn't possible to type in some input, C-n and then extend with C-w. It should be possible now with ivy-yank-word.

Owner

abo-abo commented Jun 1, 2015

My first tests were when I had point at the bol but then when the cursor is further the function ivy-yank-word yanks string from the beg of line to the point

Thanks for pointing that out, swiper should work better now. Your approach isn't optimal since it isn't possible to type in some input, C-n and then extend with C-w. It should be possible now with ivy-yank-word.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment