tweeeetyのぶろぐ的めも

アウトプットが少なかったダメな自分をアウトプット<br>\(^o^)/

【vim】ジャンプする前のカーソルの位置に戻るjump-motions - <C-o>

はじめに

もうタイトルに書いてるのが全てです

初歩的ですがたまに忘れては、そもそもこの機能の日本語での呼び方もわからず...検索するのも数分...
と何度か繰り返したので自分戒めメモです。

名前

検索するとき出てこないのでこれを気に覚えます。
Jumpjump-motionsというらしいです。

vim help

vim:help jump-motionsと打つとhelpが表示されます。
基本的な事だけコピって貼っておきます。

8. Jumps                                        jump-motions

A "jump" is one of the following commands: "'", "`", "G", "/", "?", "n",
"N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and
the commands that start editing a new file.  If you make the cursor "jump"
with one of these commands, the position of the cursor before the jump is
remembered.  You can return to that position with the "''" and "``" command,
unless the line containing that position was changed or deleted.

                                                        CTRL-O
CTRL-O                  Go to [count] Older cursor position in jump list
                        (not a motion command).
                        {not in Vi}
                        {not available without the +jumplist feature}

<Tab>           or                                      CTRL-I <Tab>
CTRL-I                  Go to [count] newer cursor position in jump list
                        (not a motion command).
                        {not in Vi}
                        {not available without the +jumplist feature}

用例

vimでファイルを開いている時、
gg(topへ移動)やG(末尾へ移動)などへ移動(これをジャンプという)した後に、元いた場所に戻りたいことがあります。
ここで<C-o>(ctrl + o)と打つ事でジャンプ元へ戻ります。

終わり

忘れぽさがひどい気がする><