Vim에서 "계속하려면 Enter 키를 누르거나 명령을 입력하십시오"프롬프트를 비활성화하려면 어떻게해야합니까?
외부 명령을 실행 한 후 나타나는 "계속하려면 Enter 키를 누르거나 명령을 입력하십시오"프롬프트를 비활성화하는 방법이 있습니까?
편집 : 해결 방법을 찾았 <CR>
습니다. 내 .lvimrc의 바로 가기에 추가 항목 을 추가하십시오 .
map <F5> :wall!<CR>:!sbcl --load foo.cl<CR><CR>
더 좋은 아이디어가 있습니까?
하나의 명령에 대해 전역 적으로 수행하는 방법을 모르겠습니다.
:silent !<command>
뒤에 공백을 포함해야합니다. silent
한 가지 해결 방법을 찾았습니다 <CR>
. map 명령에 추가 를 추가합니다 .
map <F5> :wall!<CR>:!sbcl --load foo.cl<CR><CR>
:help hit-enter
이것은 자동으로 외부 프로그램을 실행하면 텍스트 모드 vim에서 화면을 엉망으로 만드는 문제를 처리 한 방법입니다 (내 경험상 gvim은이 문제를 겪지 않습니다).
command! -nargs=1 Silent
\ | execute ':silent !'.<q-args>
\ | execute ':redraw!'
일반 자동 명령 대신 사용하십시오.
:Silent top
cmdheight
내 vimrc ( :e $MYVIMRC
) 에서를 2로 설정하십시오 .
:set cmdheight=2
vimrc 파일 의 구문 오류 일 수 있습니다.
anthony의 대답은 저를 올바른 장소로 데려 갔고 많은 메시지에서 멈추지 않도록 gvim을 구성 할 수있었습니다. 내 gvimrc 파일
에 set shortmess=aoOtI
을 추가했습니다 .
에서 제공하는 도움말 페이지에 설명되어 있습니다 :help shortmess
.
문자는보고 싶지 않거나 입력 중지 를 피하기 위해 vim이 자르기를 원하는 메시지 클래스를 의미 합니다.
나는 columns=130
gvimrc에서 넓은 초기 창을 설정하여 이전에 이것을 관리 했기 때문에 메시지가 오버플 로 되고 귀찮고 피곤하며 Enter 키를 누를 필요가 없습니다.
이것이 "Enter Enter"없이 까다로운 시나리오에서 외부 명령을 실행하는 방법입니다. 와 달리 :silent
여전히 명령 출력을 볼 수 있습니다.
명령 줄
:exe ":!<command>" | redraw
스크립트 / 기능
exe ':!<command>'
redraw
매핑 <expr>
map <expr> <F5> ":exe ':!<command>'\n:redraw\<CR>"
<expr>
함수를 호출하는 매핑
map <expr> <F5> MyFoo()
fu! MyFoo()
return ":exe ':!<command>' | redraw\<CR>"
endf
화면 지우기 전에 다시 그리기도 작동합니다. 내가 가진 것은 다음과 같습니다.
exe 'ls'
exe 'b4' "This redraws, so the Prompt is triggered
그러나 이것은 프롬프트를 트리거하지 않습니다.
exe 'ls'
redraw
exe 'b4'
당신이 사용할 수있는:
call feedkeys(" ")
예를 들면 :
function! Interactive_Questions()
echo "Question 1:"
let response1 = getchar()
echo "Question 2:"
let response2 = getchar()
" Do something
" Without the next line, you would have to hit ENTER,
" even if what is written (the questions) has no interest:
call feedkeys(" ")
endf
디렉토리에 대한 쓰기 권한이없는 디렉토리에있는 파일을 저장하는 경우 이런 일이 발생합니다. 디렉토리에서 chmod 777을했는데 (이미 파일 자체에 대한 쓰기 권한이 있습니다) "Press Enter"메시지가 더 이상 나타나지 않습니다.
비슷한 문제가 있지만 여러 파일에서 동일한 문자열을 바꾸기 위해 argdo를 실행할 때 예를 들어,
argdo %s/something/Something/eg|update
계속해서 페이지를 눌러야했습니다.
많은 프롬프트 대신 최종 프롬프트 만 있도록 스크립트를 실행하기 전에 다음 옵션을 설정할 수 있습니다.
:set nomore
- If you are using a key map then your life can be much easier by adding several more to the end of your command -- but usually 2 times is well enough.
But if you are executing a command from the vim command line. Then it's kind of tricky. You may add keyword
silent
before your actually command. It will bring you back to the vim window automatically after the command has been executed. But you still need to manually executeredraw
as some of the windows like NERD_Tree need to be redrawn.For this case, try to follow the instructions from the vim help doc:
To reduce the number of hit-enter prompts:
- Set 'cmdheight' to 2 or higher.
- Add flags to 'shortmess'.
- Reset 'showcmd' and/or 'ruler'.
This link provides another way out. Put this into your vimrc file
command! -nargs=1 Silent \ execute 'silent !' . \ | execute 'redraw!'
And then you may use :Silent command
like a regular command.
At my side the solution was to use silent
more frequently in a command chain.
Specifically before, .vimrc
had:
nnoremap M :silent make\|redraw!\|cc<CR>
This was changed to:
nnoremap M :silent make\|silent redraw!\|silent cc<CR>
Before, the "Press ENTER" not always showed up, but annoyingly often. The additional silent
s fixed this. (It looks like silent
is not needed on redraw!
as :cc
caused the "Press ENTER" message.)
This change has the drawback of no more showing the output of
:cc
, so you have to guess what's the error. A little tweak fixes this:nnoremap M :silent make\|redraw!\|cw\|silent cc<CR>
This makes the error QuickFix list (Output of
make
) automatically appear (and, by vim-magic, disappear if there is no error).
FYI:
Motivation of this M
-mapping is to just press M
in Normal-Mode to:
- save the edit (when using
make
everything is undergit
-control anyway) - invoke
make
- and directly jump to the first error or warning
My Makefile
s are usually constructed such, that this only takes a fraction of a second.
With a bit of tweaking this can be applied to non-C
type workloads as well:
In .vimrc
add
set efm+=#%t#%f#%l#%c#%m#
This allows vim
to interpret messages like following for :cc
(display error):
#E#file#line#column#message#
#W#file#line#column#message#
#I#file#line#column#message#
(E
rrors, W
arnings, I
nfo, based on vim
magic)
Example how to use this for Python scripts. (Sorry, no copy here, it's a different story.)
If your error is caused by E303, then creating a temporary directory in the .vimrc
file may fix it.
After opening any file, write and enter:
:messages
If there are errors it will prompt.
If you see E303 (Error303) "Unable to open swap file for "{filename}", recovery impossible", it may indicate that there is an old attempt to recover a swap file (most likely lost or non-existent) in the system.
To fix this, assign a temporary directory in the .vimrc
file.
To find the location of .vimrc
file, type and enter this:
$ locate .vimrc
/root/.vimrc
Open the file $ vi .vimrc
Append this to the end of the file:
set directory=.,$TEMP
Save and close with :wq
Finally, reload the profile with:
$ . /etc/profile
Try to open any file with VI. The problem shall be fixed.
'program story' 카테고리의 다른 글
Print Statement를 사용하여 VARCHAR (MAX)를 인쇄하는 방법은 무엇입니까? (0) | 2020.08.29 |
---|---|
GradientDescentOptimizer의 적응 형 학습률을 설정하는 방법은 무엇입니까? (0) | 2020.08.29 |
on ()에서도 이벤트 바인딩을 복제하지 않는 jQuery clone () (0) | 2020.08.28 |
첫 번째 git 커밋 메시지를 어떻게 바꾸나요? (0) | 2020.08.28 |
Visual Studio Code를 Git MergeTool의 기본 편집기로 사용하는 방법 (0) | 2020.08.28 |