2

Is there a way to display output at the bottom of the screen like ls does, but without scrolling down to accomodate the output?

The Vim Wiki (no https) has the following snippet

:nnoremap <A-n> :bnext<CR>:redraw<CR>:ls<CR>
:nnoremap <A-p> :bprevious<CR>:redraw<CR>:ls<CR>

I've tried binding this as

nnoremap <silent> <tab>   :bnext<cr>:redraw<cr>:ls<cr>
nnoremap <silent> <S-tab> :bprevious<cr>:redraw<cr>:ls<cr>

however, when moving to the next buffer and displaying ls, vim truncates the top n lines of the buffer, with n being the number of lines needed to display ls.

For instance, if I have the following file b.tex with line numbers:

  1 \documentclass{article}
  2
  3 \begin{document}
  4
  5 Lorem ipsem
  6
  7 $$ \frac{a}{b} $$
  8
  9 \end{document}   

And the files a.tex b.tex c.tex open, then pressing tab and navigating to b.tex produces the following output

      5 Lorem ipsem
      6
      7 $$ \frac{a}{b} $$
      8
      9 \end{document}
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"./tmp/b.tex" 9 lines --11%-- ((1) of 3)
  1 #h   "./tmp/a.tex"      line 1
  2 %a   "./tmp/b.tex"      line 1
  3  h   "./tmp/c.tex"      line 1

Is there a way to direct vim to take the four lines needed to display the output of ls from the bottom of the buffer rather than the top?

| improve this question | | | | |
  • I doubt it, but im interested to see folks try – D. Ben Knoble Jan 8 '19 at 3:55
  • 1
    Not generally possible, but you could temporarily increase the cmdheight option value – Christian Brabandt Jan 8 '19 at 6:46
  • There are some "Buffer Explorer" that might give you a different look&feel. See this question or google. – Ralf Jan 8 '19 at 15:40
  • @ChristianBrabandt so I assume there's no configurable setting that would make Vim behave this way for all commands? I'd be interested in trying to implement this change for Vim, would you happen to know roughly where this logic is defined? – henrebotha Apr 3 '19 at 15:05
  • 1
    @henrebotha have a look at msg_outtrans() in message.c – Christian Brabandt Apr 3 '19 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.