[英]How can I use a regex to replace a character that is inside two other specific characters?
[英]How can I replace a space a character for two other characters in linux with tr or sed command?
我正在編輯.vimrc文件以將vim與Ranger集成在一起,並且我有以下代碼:
fun! RangerChooser()
exec "silent !ranger --choosefile=/tmp/chosenfile " . expand("%:p:h")
if filereadable('/tmp/chosenfile')
exec 'tabnew ' . system("cat /tmp/chosenfile")
call system('rm /tmp/chosenfile')
endif
redraw!
endfun
事實是,當我嘗試使用路徑打開文件時,該文件所在的文件夾的名稱中帶有空格,但該操作失敗,因為它將中繼路徑。 我認為這是因為Ranger在空格前不使用反斜杠,因此可以理解。 這發生在第四行的系統調用中。 我添加了一些命令來插入反斜杠,但是“”和qoutes出現了一些問題。 請問有人有解決辦法嗎? 非常感謝!
shellescape()
為您完成所有這些以及更多操作:
exec "silent !ranger --choosefile=/tmp/chosenfile " . shellescape(expand("%:p:h"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.