Inicio automático de Vim con Vexplore y terminal

Inicio automático de Vim con Vexplore y terminal

Quiero configurar vim para que se comporte como un ide tradicional en su mayor parte. Lo que me gustaría hacer es que cuando escribo el comando vim se abre de esta manera:

ventana vim

El problema es que se abre de esta manera:

demostración de vim

Me gustaría que la terminal se iniciara automáticamente, pero en la ventana anterior. Intenté leer los documentos, pero no estoy muy informado sobre cómo leer la documentación y ponerla en código, la mayor parte del código en mi vimrc está copiado y pegado y algunos de los conceptos básicos ya los conocía. Me gustaría que se iniciara automáticamente como en la primera imagen.

Además, una pregunta más que no estoy seguro es posible en vim, a veces en NetRW, cuando hago clic para salir, el búfer borra el árbol de directorios y luego aparece un búfer en blanco. ¿Existe alguna forma de desactivar ciertos comandos para que no interfieran con el búfer del terminal y el listado del árbol de directorios? Un ejemplo es si intento abrir un archivo y el último búfer fue el búfer del terminal, me preguntará si quiero guardar el búfer actual (terminal) y abrir el archivo. Me gustaría que fuera más inteligente abrirlo en el buffer no terminal en lugar del terminal. Básicamente, ignorar el terminal por completo además de ingresar comandos.

Aquí está mi vimrc, probablemente un desastre ya que no hice más que copiar y pegar:

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

Respuesta1

Utilice este autocmd en su lugar:

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

Esto ejecutará toda la secuencia una vez, cuando ingrese a Vim. Estoy usando continuaciones de línea (las líneas de seguimiento comienzan con una barra invertida) y barras para ejecutar múltiples comandos. Tenga en cuenta también que autocmdejecuta comandos Ex, por lo que los comandos anteriores :no son realmente necesarios.

El primer comando abrirá la ventana NERDTree, a la izquierda, como se esperaba.

En segundo lugar, wincmd lse moverá a la ventana de la derecha (ver :help :wincmd). Ese es el paso que falta en su intento, lo que hace que el siguiente paso divida el NERDTree en lugar de la ventana principal. El wincmdnecesita ejecutarse dentro de un execute, porque de lo contrario intentará interpretar el |que le sigue, lo que dejará de funcionar como separador.

Finalmente, el último comando abre la terminal, usando un explícito rightbelow(ver :help :rightbelow) para abrir esta división en la parte inferior. ¡Eso es todo!

información relacionada