Created
April 26, 2013 05:09
-
-
Save satomixx/5465150 to your computer and use it in GitHub Desktop.
覚えておきたい Vim コマンド 備忘録 ref: http://qiita.com/mugyuu/items/755cfbb0e97d48280775
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x | |
1文字削除 | |
dd(連打) | |
1行削除 | |
dd(x行目で1回目のdを押し、y行目で2回目のdを押す) | |
x行目〜y行目までを削除 | |
5dd (xdd) | |
5(x)行削除 | |
yy | |
(x行目で1回目のを押し、y行目で2回目のyを押す) | |
x行目からy行目までをコピー | |
p | |
貼り付け | |
u | |
undo | |
CTRL + r | |
redo | |
. | |
直前のコマンドを実行 | |
= | |
選択行のインデント修正 | |
gg, V, G, = | |
ファイル全体のインデント修正 | |
CTRL + n | |
補完 | |
CTRL + p | |
前候補を検索 | |
CTRL + n | |
次候補を検索 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vim -p file1 file2 | |
open files as tabs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/hoge | |
文字列hogeを検索 | |
検索候補表示中に n | |
カーソルより下側にある検索候補に移動 | |
N | |
カーソルより上側にある検索候補に移動 | |
* | |
今単語がある位置の単語を検索 カーソルより下側 | |
# | |
今単語がある位置の単語を検索 カーソルより上側 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
■カーソル行の場合 | |
:s/置換したい対象の言葉/置換後の言葉 | |
:s/置換したい対象の言葉/置換後の言葉/g | |
■ファイル全体の場合 | |
:%s/置換したい対象の言葉/置換後の言葉/ | |
置換 | |
:%s/置換したい対象の言葉/置換後の言葉/g | |
一括置換 | |
:%s/置換したい対象の言葉/置換後の言葉/gc | |
置換対象の確認 | |
パス名などを変更する際には/を区切り文字に使うのではなく、;を使う | |
%s;/var/home;/home;gc | |
特定範囲のみ置換したい場合は置換したい行の範囲を指定する | |
[例] - 63行目から79行目まででloverをkillerに一括置換 | |
:63,79s /lover/killer/g | |
改行コードを挿入するにはCtrl+vと押した後にEnterを押す | |
以下の例ではスペースを改行に置換。 | |
:%s/ /^M/g; | |
■複数ファイルの場合 | |
argsコマンドで対象となるファイルを選び、argsdoコマンドで置換 | |
カレントディレクトリ以下にあるcファイルを対象にloverをfriendに置換。 | |
argadd **/*.c | |
:argdo %s/lover/friend/ge | update | |
buffers! | |
■複数のタブ | |
:tabdo %s/置換前文字/置換後文字/g | |
全てのタブに対して、置換 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:sp | |
上下 | |
:vs | |
左右 | |
CTRL + w(multi) | |
次の画面に移動 | |
:close | |
画面を閉じる |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:tabnew | |
:tabe filename | |
:tabclose | |
gt | |
次のタブへ | |
gT | |
前のタブへ | |
{i}gt | |
i番目のタブへ | |
:tabdo %s/置換前文字/置換後文字/g | |
全てのタブに対して、置換 | |
:tabs | |
開いてるタブをリスト表示 | |
:tabo | |
今使っているタブ以外を閉じる | |
vim -p file1 file2 | |
open files as tabs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
w | |
1文字分前へ移動 | |
b | |
1文字分後ろへ移動 | |
gg | |
最初に戻る | |
G | |
最後に進む | |
CTRL + f | |
1画面分下へ | |
CTRL + b | |
1画面分上へ | |
^ | |
行の最初へ | |
$ | |
行の終わりへ | |
f | |
fを押して文字を打ち込むと、カーソル行にあるその文字のところに進む | |
文字入力後、; を押すと戻る | |
% | |
(, ), {, }, [, ] カッコ移動などの対応する場所へ移動 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v | |
ヴィジュアルモードに入って一文字選択 | |
V | |
ヴィジュアルモードに入って一行選択 | |
CTRL + v | |
矩形(くけい)選択 (複数行選択) | |
v, gg, G | |
全選択 | |
CTRL + v, I(shift + i), input words or delete, esc | |
矩形選択後、選択範囲の編集 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:set number | |
行番号の表示 | |
:set nonumber | |
行番号の非表示 | |
:syntax on | |
カラーリング | |
:syntax off | |
カラーリングをやめる | |
:set tabstop=x | |
タブの設定 | |
:set ignorecase | |
大文字小文字の区別をなくす | |
:set noignorecase | |
区別する | |
■cit | |
c or d or i: 変更 or 削除 or 挿入 | |
i or a: 中身 or 全体 | |
t or " or ) or ] : binding character(<>. (), tag, []) | |
cit | |
タグの中身を削除して入力モードに入る | |
ca" | |
""を含んだ全体を削除して入力モードに入る |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment