How to Get Vim to do Filename Completion Even When You are Root

Posted by user12608033 on Oracle Blogs See other posts from Oracle Blogs or by user12608033
Published on Thu, 8 Nov 2012 21:56:40 +0000 Indexed on 2012/11/09 5:13 UTC
Read the original article Hit count: 166

Filed under:

From the Obscure Unix Admin Tip of the Day section...

If you occasionally edit files as root (I never do, I always use pfexec, wink wink), then you may have noticed that the vim (Vi Improved) editor that normally does filename completion via the <Tab> key now gives you something like:

:e /etc/mo^I

when you try to open up /etc/motd with a little less typing

So, there are at least three solutions to this:

  • Use <Ctrl>-E instead of <Tab>
  • Use the "-N" flag when you start Vim
  • :set wildchar=<Tab> (Enter those 5 characters, not an actual Tab)

The reason for this? It seems that when you are root, Vim sets it's "compatible" flag, which makes it behave more like its ancestor vi. In turn this makes Vim set 'wildchar' to <Ctrl>-E.

For more info, read the section you get when you enter :help cmdline-completion

© Oracle Blogs or respective owner

Related posts about /Solaris