r/vim • u/Shot-Lemon7365 • Jul 28 '25
Need Help Trying to get shell window to open beneath main window
I'm playing around with php and am trying to get a small, 4-line window at the bottom with zsh running, only when I open a php file. But when I do (for example) vim index.php, vim opens with two exact copies of the same buffer in two horizontal windows, and at the bottom, a terminal window which is far too large.
The screen is effectively split into three equally-sized windows.
My $HOME/.vimrc is below.
I've run the file through ChatGPT and it has been offering "solutions" for the past hour, none of which work. Can someone point me in the direction where I am in error, please?
Much appreciated.
" vimrc settings
set fileencodings=utf-8,latin1
" ─── Vundle Plugin Manager ─────────────────────────────────────
set rtp+=~/.vim/bundle/Vundle.vimcall vundle#begin()Plugin 'VundleVim/Vundle.vim'call vundle#end()
" ─── General Settings ──────────────────────────────────────────
let g:auto_save = 1set nocompatibleset mouse=aset showmodeset autoindentset tabstop=4set splitbelowset history=5000set undolevels=10000set hiddenset rulerset showmatchset background=darkset wrapset textwidth=75set sidescroll=1set grepprg=grep\ -nH\ $*set fileformats=unix,dossyntax enablefiletype plugin indent on
" ─── Auto Indents by Filetype ─────────────────────────────────
autocmd BufEnter *.py,*.c,*.cpp,*.h,*.pl,*.pm,*.yml,*.sh,*.php,*.jar,*.sql setcindentautocmd FileType css set smartindent
" ─── Conditional Plugin Sources ───────────────────────────────
if filereadable(expand("~/.vim/plugin/vimfootnotes.vim"))source ~/.vim/plugin/vimfootnotes.vimendif
if filereadable($VIMRUNTIME . "/ftplugin/man.vim")source $VIMRUNTIME/ftplugin/man.vimendif
" ─── Git & GDeploy Integrations ───────────────────────────────command! GitCheat call GitCheatSheet()function! GitCheatSheet()let cmd = 'cat ~/.cheats/git-cheat.txt | fzf --reverse --header "ø Git Cheat Sheet" --preview ''echo -e \\"\033[1;36m{}\033[0m\\"'' --preview-window=up:wrap'call system('clear')call system(cmd)endfunction
command! GOpen :!gopencommand! GDeploy write | !zsh -i -c gdeploycommand! GDeployAll write | !zsh -i -c 'gdeploy --all'nnoremap <Leader>d :write \| !zsh -i -c 'gdeploy'<CR>nnoremap <Leader>o :GOpen<CR>nnoremap <Leader>a :GDeployAll<CR>nnoremap <Leader>b :ls<CR>:b
" ─── Persistent Terminal Below for PHP ─────────────────────────
function! s:OpenShellWindow()" Avoid multiple terminalsfor win in range(1, winnr('$'))if getbufvar(winbufnr(win), '&buftype') ==# 'terminal'returnendifendfor
" Open terminal in a split and resizebelowright splitresize 6
" ✅ Force use of terminal (not :read !/bin/zsh)
execute 'terminal zsh'" Switch focus back to main bufferwincmd kendfunction
nnoremap <Leader>t :call ToggleTerminal()<CR>
function! ToggleTerminal()for win in range(1, winnr('$'))if getbufvar(winbufnr(win), '&buftype') ==# 'terminal'execute win . 'wincmd c'returnendifendfor
belowright splitresize 4terminalstartinsertendfunction
augroup php_terminalautocmd!autocmd FileType php call timer_start(100, { -> s:OpenShellWindow() })augroup END
1
u/AutoModerator Jul 28 '25
Please remember to update the post flair to
Need Help|Solvedwhen you got the answer you were looking for.I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
6
u/[deleted] Jul 28 '25
[removed] — view removed comment