Vim-vim을 시작할 때 즉시 명령을 실행하는 방법은 무엇입니까?
:FindFileCache .빠른 열기를 위해 파일 캐시를 수집하기 위해 vim을 시작할 때마다 실행해야하는 플러그인 (FindFile.vim)이 있습니다. 그래도 vim을 시작할 때마다 이것을 실행해야합니다 .
vim이 시작될 때마다 한 번 실행되는 명령을 어떻게 작성할 수 있습니까?
구성 항목을 보관하는 가장 좋은 위치는 .vimrc 파일입니다. 그러나 너무 일찍 공급되었으므로 :h startup다음을 확인하십시오 .
At startup, Vim checks environment variables and files and sets values
accordingly. Vim proceeds in this order:
1. Set the 'shell' and 'term' option *SHELL* *COMSPEC* *TERM*
2. Process the arguments
3. Execute Ex commands, from environment variables and/or files *vimrc* *exrc*
4. Load the plugin scripts. *load-plugins*
5. Set 'shellpipe' and 'shellredir'
6. Set 'updatecount' to zero, if "-n" command argument used
7. Set binary options
8. Perform GUI initializations
9. Read the viminfo file
10. Read the quickfix file
11. Open all windows
12. Execute startup commands
보시다시피 .vimrc 는 플러그인보다 먼저로드됩니다. 입력하면 :FindFileCache .해당 명령이 아직 존재하지 않기 때문에 오류가 발생합니다. (4 단계에서 플러그인이로드되면 존재합니다.)
이를 해결하려면 명령을 직접 실행하는 대신 자동 명령을 생성하십시오. 자동 명령은 이벤트가 발생할 때 일부 명령을 실행합니다. 이 경우 VimEnter 이벤트가 적절 해 보입니다 (에서 :h VimEnter).
*VimEnter*
VimEnter After doing all the startup stuff, including
loading .vimrc files, executing the "-c cmd"
arguments, creating all windows and loading
the buffers in them.
그런 다음 .vimrc에 다음 줄을 넣으십시오 .
autocmd VimEnter * FindFileCache .
vim의 -c 플래그도 있습니다. vim이 수직 분할로 시작되도록 tmuxp 구성에서 이것을 수행합니다.
vim -c "vnew"
이름이 지정된 파일을 ~/.vim/after/plugin/whatever_name_you_like.vim만들고 다음으로 채 웁니다.
FindFileCache .
vim 디렉토리에서 스크립트를 읽고 실행하는 순서는 다음에 설명되어 있습니다. :help 'runtimepath'
다른 답변보다 늦게 시작하지만 시작 직후에는 .vimrc에서 타이머를 사용하십시오. 예를 들어 .vimrc의이 코드는 변수를 설정하기 전에 시작 후 0.5 초 동안 대기합니다.
function DelayedSetVariables(timer)
let g:ycm_filetype_blacklist['ignored'] = 1
endfunction
let timer=timer_start(500,'DelayedSetVariables')
(The variable in the example is the blacklist from YouCompleteMe plugin. I assume, the plugin starts up some other process asynchronously which then creates variables, but is not quite ready by the time vim has started. The variable does not exist when I try to set it in .vimrc, an after file, or VimEnter event. This is specific to my Windows system somehow, YCM documentation says .vimrc should work for setting options.)
Put FindFileCache in your .vimrc.
Autload commands are different and will not work for your scenario.
참고URL : https://stackoverflow.com/questions/6821033/vim-how-to-run-a-command-immediately-when-starting-vim
'Programing' 카테고리의 다른 글
| Visual Studio HTML Designer는 어디에 있습니까? (0) | 2020.09.07 |
|---|---|
| 진행 상황을 제외하고 어떻게 명령 줄에서 robocopy를 무음으로 만들 수 있습니까? (0) | 2020.09.07 |
| apt-get : 명령을 찾을 수 없습니다. (0) | 2020.09.07 |
| 메타 프로그래밍을위한 Python 대 Ruby (0) | 2020.09.07 |
| 편집기에 기본 유형이 없습니다. (0) | 2020.09.07 |