为何vi将.lrp后缀文件识别为tar文件且无法编辑?
Hey there! I’ve dealt with this exact frustrating issue across multiple Linux distros and macOS too—here’s what’s going on and how to fix it permanently.
What’s Causing the Error?
Vim’s built-in tar.vim plugin (which handles browsing tar archive files) automatically associates the .lrp file extension with tar-based archives. LRP files (used for Linux Router Project systems) do have tar-like components, but they aren’t standard tar archives—so when Vim tries to load them in tar browse mode, it throws that red ***error*** (tar#Browse) message.
Since this is part of Vim’s default plugin behavior, it’s why you’re seeing it across OS X High Sierra, Ubuntu 16.04, Debian, and your colleagues’ devices, regardless of .vimrc tweaks (unless your config overrides this association).
Quick Temporary Fixes
If you just need to edit a .lrp file right now:
- Open the file with the
++nopluginflag to skip the tar plugin for this session only:vi ++noplugin yourfile.lrp - Or once Vim is open and showing the error, run this command to reset the filetype and disable the tar mode:
:set filetype=text
Permanent Solution (No More Errors!)
To make Vim stop treating .lrp files as tar archives forever, add one of these lines to your ~/.vimrc (or ~/.vim/vimrc on some systems):
Option 1: Force .lrp files to use plain text mode
This is the simplest approach:
autocmd BufNewFile,BufRead *.lrp set filetype=text
Option 2: Tell the tar plugin to ignore .lrp files
If you want to keep other tar-related associations intact but exclude .lrp, use this:
autocmd BufRead,BufNewFile *.lrp let b:tar_ignore=1
After saving your .vimrc, restart Vim—you’ll be able to edit .lrp files normally without any red error bars.
内容的提问来源于stack exchange,提问作者Balthasar

