LoginSignup
24
24

More than 5 years have passed since last update.

Goソースをgrep → pecoで選択 → vimで該当行番号にジャンプした状態で開くワンライナー

Last updated at Posted at 2014-08-14

こんな感じ

※コメント行も含めたければ途中の| grep -v "[0-9]:\s*//"を省略する

oneliner
% vi $(grep -n <STRING> **/*.go | grep -v "[0-9]:\s*//" | peco | awk -F ":" '{print "-c "$2" "$1}')

自分はzshrcに↓こういう関数用意して、vig <STRING>って使い方してる

.zshrc
function vig {
    STR="$1"
    vi $(grep -n ${STR} **/*.go | grep -v "[0-9]:\s*//" | peco | awk -F ":" '{print "-c "$2" "$1}')
}

動作確認環境

grepのバージョンは下記2つで試した。

% grep --version
GNU grep 2.5.3

Copyright (C) 1988, 1992-2002, 2004, 2005  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% grep --version
grep (BSD grep) 2.5.1-FreeBSD
24
24
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
24
24