Vim은 Vexplore와 터미널을 사용하여 자동으로 시작됩니다.

Vim은 Vexplore와 터미널을 사용하여 자동으로 시작됩니다.

대부분의 상황에서 기존 IDE처럼 작동하도록 vim을 설정하고 싶습니다. 내가 하고 싶은 것은 vim 명령을 입력하면 다음과 같이 열리는 것입니다:

빔 창

문제는 다음과 같이 열린다는 것입니다.

vim 데모

터미널이 자동으로 시작되지만 이전 창에서 시작되기를 원합니다. 문서를 읽으려고 했지만 문서를 읽고 코드에 넣는 방법을 모르겠습니다. vimrc에 있는 대부분의 코드는 복사하여 붙여넣은 코드이고 일부 기본 내용은 이미 알고 있습니다. 첫 번째 사진처럼 자동으로 시작되게 하고 싶습니다.

또한 vim에서 가능한지 확실하지 않은 한 가지 문제는 NetRW에서 버퍼를 클릭하면 디렉토리 트리가 지워지고 빈 버퍼가 나타나는 경우가 있다는 것입니다. 특정 명령이 터미널 버퍼 및 디렉터리 트리 목록을 방해하지 않도록 비활성화하는 방법이 있습니까? 예를 들어 파일을 열려고 하는데 마지막 버퍼가 터미널 버퍼인 경우 현재 버퍼(터미널)를 저장하고 파일을 열 것인지 묻는 메시지가 표시됩니다. 비 터미널 영역의 버퍼링에 대해 더 똑똑해지기를 원합니다. 터미널 대신. 기본적으로 명령 입력을 제외하고는 터미널을 완전히 무시합니다.

여기 내 vimrc가 있습니다. 복사하여 붙여넣기만 했기 때문에 혼란스러울 수도 있습니다.

set mouse=a
set number
imap jj <Esc>
set autochdir
map <Tab> <C-W>W:cd %:p:h<CR>:<CR>
map <C-l> :q!<CR>
map <C-t> :term bash<CR>
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')

" Make sure you use single quotes

" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'

" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'

" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

" On-demand loading
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }

" Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }

" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }

" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }

" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }

" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'

" Initialize plugin system
call plug#end()


function! NetrwOpenMultiTab(current_line,...) range
   " Get the number of lines.
   let n_lines =  a:lastline - a:firstline + 1

   " This is the command to be built up.
   let command = "normal "

   " Iterator.
   let i = 1

   " Virtually iterate over each line and build the command.
   while i < n_lines
      let command .= "tgT:" . ( a:firstline + i ) . "\<CR>:+tabmove\<CR>"
      let i += 1
   endwhile
   let command .= "tgT"

   " Restore the Explore tab position.
   if i != 1
      let command .= ":tabmove -" . ( n_lines - 1 ) . "\<CR>"
   endif

   " Restore the previous cursor line.
   let command .= ":" . a:current_line  . "\<CR>"

   " Check function arguments
   if a:0 > 0
      if a:1 > 0 && a:1 <= n_lines
         " The current tab is for the nth file.
         let command .= ( tabpagenr() + a:1 ) . "gt"
      else
         " The current tab is for the last selected file.
         let command .= (tabpagenr() + n_lines) . "gt"
      endif
   endif
   " The current tab is for the Explore tab by default.

   " Execute the custom command.
   execute command
endfunction

" Define mappings.
augroup NetrwOpenMultiTabGroup
   autocmd!
   autocmd Filetype netrw vnoremap <buffer> <silent> <expr> t ":call NetrwOpenMultiTab(" . line(".") . "," . "v:count)\<CR>"
   autocmd Filetype netrw vnoremap <buffer> <silent> <expr> T ":call NetrwOpenMultiTab(" . line(".") . "," . (( v:count == 0) ? '' : v:count) . ")\<CR>"
augroup END

" Toggle Vexplore with Ctrl-E
function! ToggleVExplorer()
  if exists("t:expl_buf_num")
      let expl_win_num = bufwinnr(t:expl_buf_num)
      if expl_win_num != -1
          let cur_win_nr = winnr()
          exec expl_win_num . 'wincmd w'
          close
          exec cur_win_nr . 'wincmd w'
          unlet t:expl_buf_num
      else
          unlet t:expl_buf_num
      endif
  else
      exec '1wincmd w'
      Vexplore
      let t:expl_buf_num = bufnr("%")
  endif
endfunction

" NeTRW Explorer Settings

let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 15
augroup ProjectDrawer
  autocmd!
  autocmd VimEnter * :Vexplore
augroup END
map <silent> <C-n> :Vexplore<CR>

" Per default, netrw leaves unmodified buffers open. This autocommand
" deletes netrw's buffer once it's hidden (using ':q', for example)
autocmd FileType netrw setl bufhidden=delete
autocmd TabNew * call feedkeys(":Vexplore\<CR>", 'n')

" terminal split below
set splitbelow
autocmd VimEnter * :term bash

답변1

대신 다음 자동 명령을 사용하십시오.

autocmd VimEnter *
    \ Vexplore |
    \ execute "wincmd l" |
    \ rightbelow term bash

Vim에 들어가면 전체 시퀀스가 ​​한 번 실행됩니다. 여러 명령을 실행하기 위해 줄 연속 문자(다음 줄은 백슬래시로 시작)와 막대를 사용합니다. 또한 autocmdEx 명령이 실행되므로 이전 명령이 :실제로 필요하지 않습니다.

첫 번째 명령은 예상대로 왼쪽에 NERDTree 창을 엽니다.

둘째, wincmd l오른쪽 창으로 이동합니다( 참조 :help :wincmd). 이는 시도에서 누락된 단계로, 이로 인해 다음 단계에서 기본 창 대신 NERDTree가 분할됩니다. wincmd내부적으로 실행 해야 합니다 execute. 그렇지 않으면 뒤에 오는 내용을 해석하려고 시도하여 |구분 기호로 작동하지 않습니다.

마지막으로 마지막 명령은 터미널을 열고 명시적 rightbelow(참고자료 참조 :help :rightbelow)을 사용하여 하단 분할을 엽니다. 그게 다야!

관련 정보