0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vim個人的コマンドまとめ

Posted at

サーバーで見るときvim使う機会があると思うので、個人的まとめです。

vimでバイナリを編集する

$ vim -b file.bin
:%!xxd
バイナリ見ても、実際右にでてくるものをいじっても無意味

保存するときは
:%!xxd -r
してからじゃないと、そのままになるので注意
参考資料:https://qiita.com/urakarin/items/337a0433a41443731ad0

ctags

ctags -R .で現状のディレクトリに作成
Ctrl-]:宣言元に飛び
Ctrl+t:戻る

homeディレクトリまでctagsがあるか確認する
.vimrc

set tags=.tags;$HOME

option

余白の場合の差分は比較しない(常に追加すると逆に気づけなくなるのでコマンドベースのほうがよさそう)
:set diffopt=iwhite

Vimdiff

vimdiff fail1 fail2でdiffmodeで開く

Vimdiffよくつかうコマンド

zR:vimdiffの全てを開く
]+c:次の差分
[+c:前の差分
diffget:差分を受け入れる
diffput:差分を向こう側に入れる

コマンド

% 対応した括弧({}等)に移動します。

git difftoolでvimdiff実施

git config --global diff.tool vimdiff
git config --global difftool.prompt false
git config --global merge.tool vimdiff
git config --global mergetool.prompt false

あとはgit difftool fileとかでvimdiffでみれる

viで開いて、vsで水平展開してdiffをとる

:vs filename
:windo diffthis
//offする場合
:windo diffoff

vimdiffのカラー設定(目に優しくない、もうちょっとなんとかしたい)

~/.vimrcに追加
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=darkred
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=darkblue
highlight DiffChange cterm=bold ctermfg=10 ctermbg=brown
highlight DiffText cterm=bold ctermfg=10 ctermbg=darkmagenta

Vimgrep&結果をQuickfixに表示

:vimgrep sample /decompress/ * | cw
ctrl + oで戻る

参考資料

https://sgry.jp/blog/2014/11/24/1811/comment-page-1/
https://qiita.com/aratana_tamutomo/items/59fb4c377863a385e032

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?