Luis A. Florit wrote:
Hi,

    I would like Vim to show 'virtual' characters instead of real
characters. For example, I want Vim to show 'password=******'
instead of the actual password when editing a file, but without
modifying the password content. For example, when folding, vim
does this. It replaces the whole block with a 'virtual' line
that is not really in the file. How does Vim do this?

    Many thanks,

        Luis.




Showing asterisks when the buffer contains something else is not possible AFAIK (except by hacking the C code, see below). However, in color consoles and in the gui, you can display anthing in "invisible" colors (foreground the same as background) by defining the syntax accordingly. (Define, for instance, a syntax group myPasswordValue with appropriate ":syntax" definitions, and link the corresponding highlight group to Invisible). However, the "invisible" text may reappear if, for instance, you select it in Visual mode. For example, recent versions of syntax/help.vim for Vim 7.0 use invisible text for the *stars* and |bars| which delimit helptags in the Vim help files.

There is also Vince Negri's conceal/ownsyntax patch, which allows hiding parts of a line the way folding hides parts of a page, and even displaying "replacement text" different from what is in the buffer. It resides at http://vince.negri.googlepages.com/ and requires recompiling Vim.

Of course, having passwords in cleartext in a disk file is something intrinsically unsafe.


Best regards,
Tony.

Reply via email to