在 Vim 中使用 grep 搜尋文本

在 Vim 中使用 grep 搜尋文本

我正在 vim 中做一些練習,但遇到了問題。我需要在與我的 vim 檔案位於同一目錄中的另一個檔案中找到一段文字。我使用 grep 找到它,但出現錯誤。 “情況不好”我需要使用什麼來強制 grep 走出 vim 文件並在“index.html”文件中搜索?這是我的 grep 程式碼:

i = ${grep data-buying index.html | grep USD | grep -oh '[0-9].[0-9]*' | head -n 1}

這裡出了什麼問題?

答案1

嘗試:read !grep data-buying index.html | grep USD | grep -oh '[0-9].[0-9]*' | head -n 1

:read !command將運行command並且標準輸出將被讀入遊標所在位置的目前緩衝區。

相關內容