-
Notifications
You must be signed in to change notification settings - Fork 51
Enno edited this page Jul 10, 2019
·
7 revisions
If you have lesspipe installed (as it is by default on Ubuntu, albeit a version under different authorship), adding these lines
if exists('g:did_load_filetypes')
if executable('lesspipe.sh')
let s:lesspipe_cmd = 'LESSQUIET=1 lesspipe.sh'
elseif executable('lesspipe')
let s:lesspipe_cmd = 'lesspipe'
endif
if exists('s:lesspipe_cmd') && executable('file')
augroup lesspipe
autocmd!
autocmd BufReadPost *
\ if empty(&l:buftype) && !did_filetype() && !&l:binary && filereadable(bufname('%')) &&
\ system('file --mime --brief ' . shellescape(fnamemodify(resolve(expand('%')), ':p'))) !~# '^text/' |
\ silent exe '%!' . s:lesspipe_cmd . ' ' . shellescape(expand('%')) |
\ setlocal filetype=text nomodifiable readonly |
\ endif
augroup END
endif
endif
to your vimrc
lets you view all unrecognized files in Vim through lesspipe, if not explicitely intended otherwise, for example, by passing the parameter -b
(for binary) on the command line.
Since Vim sets a filetype for pdf
files, to read their text by lesspipe, too, add
autocmd Filetype pdf
\ exe '%!' . s:lesspipe_cmd . ' ' . shellescape(expand('%')) |
\ setlocal filetype=text nomodifiable readonly |
before augroup END
above.
To ensure that Vim
displays the text contained in a Microsoft Office or EPUB document instead of listing the files it archives (by the zipPlugin
, see :help zip
),
- either exclude these file types from those handled by
zipPlugin
by adding
" Remove extensions jar?|epub|doc[xm]|xls[xmb]|pp[st][xm] from g:zipPlugin_ext
" from Sep 13, 2016 and afterwards add back whenever converter unavailable
let g:zipPlugin_ext='*.apk,*.celzip,*.crtx,*.ear,*.gcsx,*.glox,*.gqsx,*.kmz,*.oxt,*.potm,*.potx,*.ppam,*.sldx,*.thmx,*.vdw,*.war,*.wsz,*.xap,*.xlam,*.xlam,*.xltm,*.xltx,*.xpi,*.zip'
to your vimrc
,
- or disable it altogether by adding
let g:loaded_gzip = v:true
to your vimrc
,