Luis A. Florit wrote:
* El 23/08/06 a las 21:03, Tim Chase chamullaba:
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?
It sounds like you're trying to do two diff. things. One would
be described as "vertical folding". There's an unofficial patch
floating around that does it...you can learn more (and download
the patch) from
http://vince.negri.googlepages.com/concealownsyntaxforvim
However, if you're just looking for a way to hide passwords, you
might try exploiting syntax highlighting to make the text
foreground and background the same color.
hi Password ctermfg=red ctermbg=red cterm=NONE guifg=red guibg=red
followed by
match Password /password\s*=\s*\zs.*/
(adjust colors to taste...you may or may not want to see
something that would give away the password-length, so you might
prefer to use your default background color for the Password
group. Using asterisks would give away the length, so it may not
matter to you)
It doesn't quite handle some oddball cases such as when you're
visually selecting the line, or when the cursor is on the
password (where you'll see the character under the cursor), if
you have 'hls' set and your search matches something in the
password, or possibly when folded. I'm sure there are other
instances where it might give you a little grief, but it's a good
first-pass attempt to hide passwords. :)
Oh, what a mess...
I tried to make myself more clear, and obtained the opposite.
I know the password trick via highlighting.
I use it for my fetchmailrc files.
I don't want to hide passwords.
I just want to replace some text by another, without
changing the file. Only an apparent, visual change.
Like folding: you replace 10 lines by one,
but you are not really replacing the lines in the file.
It is just a visual trick.
What I want should be possible, since folds do exactly that.
Sorry for the mess....
Luis.
IIUC, it is not possible "out of the box", but it is possible if you
recompile with Vince's patch mentioned both in Tim's reply quoted above
and in mine.
Best regards,
Tony.