2
我寫了一個函數,它在我正在編輯的文件上執行一些搜索和替換。但是對於某些文件(在文件名中有一些特定的關鍵字),我需要添加一些特定的搜索並將其限制爲這些文件。如何使用特定字符串在文件名上添加特定搜索和替換模式
我需要知道如何解決下面的代碼:
function! Test()
" basic search and replace for all the files
%s/I'll /I will /ge
" if the filename starts with "blah-" the following additional search and replace needed otherwise not
if match(readfile(expand('%:t')),"^blah-")
%s/could'nt /could not /gec
endif
endfunc
而且在調用該函數:call Test()
所有這些模式將被執行。因此,我不需要擔心某些文件類型的具體說明。
任何人都可以幫我解決這個問題嗎?