검색을 완료하면 출력 메시지를 변경하고 싶습니다.검색의 출력 메시지를 변경하는 방법은 무엇입니까?
p.e. 매우 긴 정규식으로 검색 할 때 아무 것도 발견되지 않을 때 vim이 메시지를 반환합니다. E486: Pattern not found: .... very long regex code ...
출력을 캡처하고이 메시지를 변경하고 싶습니다. 어떻게해야합니까?
검색을 완료하면 출력 메시지를 변경하고 싶습니다.검색의 출력 메시지를 변경하는 방법은 무엇입니까?
p.e. 매우 긴 정규식으로 검색 할 때 아무 것도 발견되지 않을 때 vim이 메시지를 반환합니다. E486: Pattern not found: .... very long regex code ...
출력을 캡처하고이 메시지를 변경하고 싶습니다. 어떻게해야합니까?
:s[ubstitute]
명령은 오류를 표시하지 않기 위해 /e
플래그가 있지만 AFAIK도 :silent /foo
이라도 오류 메시지가 표시되지 않습니다. 글쎄, 당신은 그것을 억압하고 싶지 않습니다, 어쨌든, 당신은 그것을 "포착"하고 다른 것을 보여주고 싶습니다.
모든 언어와 마찬가지로 vimscript에는 try/catch
이 있습니다. 당신은 :h :try
에서 그것을 읽을 수 있습니다.
try
/foo
catch /^Vim\%((\a\+)\)\=:E486/
let @n = v:exception
echo "No luck!"
endtry
당신은 당신이 noremap
/
나는 당신이 vimscript에서 오류 메시지를 잡는 것에 대해 이야기하고 있다고 생각합니다.
그럼 당신은 catch
을 체크 아웃 할 수 있습니다 : 검색을 할 :h catch
*:cat* *:catch* *E603* *E604* *E605*
:cat[ch] /{pattern}/ The following commands until the next |:catch|,
|:finally|, or |:endtry| that belongs to the same
|:try| as the ":catch" are executed when an exception
matching {pattern} is being thrown and has not yet
been caught by a previous ":catch". Otherwise, these
commands are skipped.
When {pattern} is omitted all errors are caught.
Examples: >
:catch /^Vim:Interrupt$/ " catch interrupts (CTRL-C)
:catch /^Vim\%((\a\+)\)\=:E/ " catch all Vim errors
:catch /^Vim\%((\a\+)\)\=:/ " catch errors and interrupts
:catch /^Vim(write):/ " catch all errors in :write
:catch /^Vim\%((\a\+)\)\=:E123/ " catch error E123
:catch /my-exception/ " catch user exception
:catch /.*/ " catch everything
:catch " same as /.*/
블록 try
에 다음 오류 메시지를 잡을 수 있고, 당신이 원하는 무엇이든 할.
에 당신이 내 질문을 downvote 당신이 그것을 downvote 이유를 말해 경우 이름을 적어주세요 기능에
try/catch
을 포장 할 수있다. tnx. – Reman