[英]vim path completion in command mode
在 vim 中,如果你點擊:e <tab><tab>
,vim 會完成一些路徑。
但是,我想打開a/b/c/d.cpp
,我中風:e <tab><tab>
並找到AA
。
我想找到AA
子目錄。 或者,我按/
鍵。
示例:e AA//BB//CC//DD.cpp
還有別的好辦法嗎? 總之,我想知道命令:e
子目錄的完整路徑。
命令行完成允許您使用通配符。
基本的*
表示“任何字符”:
:e *<Tab> " similar to plain <Tab>
:e foo*<Tab> " completes only files starting with 'foo'
更高級的**
表示“任何子目錄”:
:e **/<Tab> " completes every file under every subdirectory
" of the current working directory
:e **/*foo<Tab> " completes every file ending with 'foo' under every subdirectory
" of the current working directory
請參閱:help file-searching
。
順便說一下,它是“命令行模式”。 “命令模式”只是“正常模式”的另一個名稱。
這個答案是基於你想要選擇正確文件進行編輯的路徑的假設。
我可以建議在正確設置路徑后使用:find
。 這將節省額外的大量打字。
您可以從設置:set path+=**
(這也將搜索子目錄)開始。 現在你可以簡單地做
:find d.cpp
vim 將為您完成剩下的工作。 它會找出d.cpp
的路徑並打開它。 它的優點在於它允許使用通配符,例如:find d.*
或:find *.cpp
。
如果您不想使用find
並繼續使用edit
,那么:set wildmenu
可能會很有用。 這將顯示您可以使用選項卡迭代的所有可用選項
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.