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

[数値]+検索(n/N)の動作を変更する #10

Closed
Kocha opened this issue Sep 18, 2013 · 7 comments
Closed

[数値]+検索(n/N)の動作を変更する #10

Kocha opened this issue Sep 18, 2013 · 7 comments

Comments

@Kocha
Copy link

Kocha commented Sep 18, 2013

ちょっとこんなこと出来たらいいなレベルで申し訳ないのですが、
現在の Vim動作が 10nと入力すると現在位置から 10個後の検索位置まで飛びます。
anzu(20/100) と表示されている場合だと、 anzu(30/100)
10N だと、anzu(10/100) みたいな動作です。

で、こんなこと出来たらいいなというのが、
10n と入力したら、anzu(10/100) と必ず指定した個数値に飛ぶように出来ないかと。
40n だと、anzu(40/100)
行数指定みたいなイメージです。

思いつきIssue立ててしまい申し訳ないのですが、
ご意見いただければ幸いです。

@osyo-manga
Copy link
Owner

ありがとうございます。
面白そうなので実装してみます。

@Kocha
Copy link
Author

Kocha commented Sep 18, 2013

おぉぉ。
よろしくお願いします><

@osyo-manga
Copy link
Owner

実装してみました。
使い方は以下のような感じになります。

" 最後に検索したワードの先頭から数えて [count] の位置へ移動する
" 10<Leader>j であれば先頭から10番目のワードの位置へ移動する
nmap <Leader>j <Plug>(anzu-jump)
" ステータス情報をコマンドラインに出力する場合はこちら
" nmap <Leader>j <Plug>(anzu-jump)<Plug>(anzu-echo-search-status)


" 最後に検索したワードの先頭から数えて [count] 位置へ移動する
" [count] がなければ <Plug>(anzu-n) を使用する
nmap n <Plug>(anzu-jump-n)

" 位置をコマンドラインに出力したい場合
nmap n <Plug>(anzu-jump-n)<Plug>(anzu-echo-search-status)

" カーソル近くの単語を検索する場合
nmap n <Plug>(anzu-jump-star)

まだあまり試していないのでバグなどがあれば教えて頂けると助かります。

@Kocha
Copy link
Author

Kocha commented Sep 20, 2013

実装ありがとうございます。
軽く試してみて、思ったとおりの動きになっており感激しております。
1点だけ、気になる点がありました。
set nowrapscan 設定時に、候補の一番最後で n を入力すると
function anzu#jump_keyの処理中にエラーが検出されました。 と出ます。

nmap n <Plug>(anzu-jump-n)

で設定しております。

@osyo-manga
Copy link
Owner

ありがとうございます。
対応してみたので試してみて下さい。

@Kocha
Copy link
Author

Kocha commented Sep 20, 2013

試しました!ありがとうございます。
お陰さまでもう nowrapscanは設定しないと思います。

@Kocha Kocha closed this as completed Sep 20, 2013
@osyo-manga
Copy link
Owner

ありがとうございました。

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