1

I tried vim/less.sh as pager with syntax highlighting, but there is a little issue: when displaying small file, vim uses 'full screen' and waits for a command from user.

Can I let vim to act like a less --quit-at-eof?

In other words, is there a way to automatically quit vim if displayed file is several lines length?

I found one solution with a shell script: count file lines by wc -l, then get terminal height, if size is small - use custom vim config file, where custom config file ending with :quit string.

However, this solution looks terrible and leave extra lines with ~ after end of small file, so I'm looking for better way to do this.

fedorqui
  • 275,237
  • 103
  • 548
  • 598
Victor Istomin
  • 1,107
  • 8
  • 14
  • `In other words, is there a way to automatically quit vim if displayed file is several lines length?` In another words, if your file has *several* lines length, vim shouldn't open/display it at all? – Kent Sep 25 '13 at 14:04
  • No, on my system (FreeBSD 8.2) is doesn't switch to alternate terminal page, so content is still displayed after exit. – Victor Istomin Sep 26 '13 at 09:33

1 Answers1

2

Vim switches to the alternate terminal page, so when you exit it, its contents are gone. Even if you turn that off:

$ vim --cmd 'set t_ti= t_te='

UI stuff like the ~, ruler and statusline would remain, too. Therefore, the solution you've found looks like a reasonable workaround. Either use that or (better) get used to quitting the Vim pager.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324