Skip to content

Update usr_05.{txt,jax} #2042

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

Merged
merged 1 commit into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions doc/usr_05.jax
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*usr_05.txt* For Vim バージョン 9.1. Last change: 2025 Mar 22
*usr_05.txt* For Vim バージョン 9.1. Last change: 2025 Apr 10

VIM USER MANUAL - by Bram Moolenaar

Expand Down Expand Up @@ -314,24 +314,28 @@ CTRL-U でアンドゥすることができます。":iunmap <C-U>" で元に戻
|:filetype-indent-on| と 'indentexpr' 参照。


*restore-cursor* *last-position-jump* >
*restore-cursor* *last-position-jump* >vim
augroup RestoreCursor
autocmd!
autocmd BufReadPost *
\ let line = line("'\"")
\ | if line >= 1 && line <= line("$") && &filetype !~# 'commit'
\ && index(['xxd', 'gitrebase'], &filetype) == -1
\ && !&diff
\ | execute "normal! g`\""
\ | endif
augroup END

自動コマンドをもう一つ。ファイルを読み込んだ直後に実行される自動コマンドを定義
しています。後ろのごちゃごちゃした部分は「'" マークが定義されているかどうかを
チェックし、定義があればそこにジャンプする」という意味です。コミットやリベース
メッセージの場合は、前回とは違うメッセージになる可能性が高く、また、xxd(1) を
使ってバイナリファイルをフィルタリングして編集を行う場合は、入力ファイルを行っ
たり来たり変換して、いわば二面性を持っているため、このようなことは行いません。
|using-xxd| も参照してください。
チェックし、定義があればそこにジャンプする」という意味です。以下の場合にはこの
処理は実行されません:
- コミットやリベースメッセージの場合は、前回とは違うメッセージになる可能性が
高い
- xxd(1) を使ってバイナリファイルをフィルタリングして編集を行う場合は、入力
ファイルを行ったり来たり変換して、いわば二面性を持っているため (|using-xxd|
も参照)
- Vim が diff モードになっている

コマンドを複数行に分けて書くために、行頭に "\" を書いています。行がやたらと長
くなるのを防ぐためです。|line-continuation| 参照。"\" は Vim script 内でのみ使
Expand Down
16 changes: 10 additions & 6 deletions en/usr_05.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*usr_05.txt* For Vim version 9.1. Last change: 2025 Mar 22
*usr_05.txt* For Vim version 9.1. Last change: 2025 Apr 10

VIM USER MANUAL - by Bram Moolenaar

Expand Down Expand Up @@ -307,23 +307,27 @@ This switches on three very clever mechanisms:
filetypes. See |:filetype-indent-on| and 'indentexpr'.


*restore-cursor* *last-position-jump* >
*restore-cursor* *last-position-jump* >vim
augroup RestoreCursor
autocmd!
autocmd BufReadPost *
\ let line = line("'\"")
\ | if line >= 1 && line <= line("$") && &filetype !~# 'commit'
\ && index(['xxd', 'gitrebase'], &filetype) == -1
\ && !&diff
\ | execute "normal! g`\""
\ | endif
augroup END

Another autocommand. This time it is used after reading any file. The
complicated stuff after it checks if the '" mark is defined, and jumps to it
if so. It doesn't do that for a commit or rebase message, which are likely
a different one than last time, and when using xxd(1) to filter and edit
binary files, which transforms input files back and forth, causing them to
have dual nature, so to speak. See also |using-xxd|.
if so. It doesn't do that when:
- editing a commit or rebase message, which are likely a different one than
last time,
- using xxd(1) to filter and edit binary files, which transforms input files
back and forth, causing them to have dual nature, so to speak (see also
|using-xxd|) and
- Vim is in diff mode

The backslash at the start of a line is used to continue the command from the
previous line. That avoids a line getting very long. See |line-continuation|.
Expand Down