Steven M. Klass wrote:
> Can someone explain what this does and how do I use it?
>
> It's in my .vimrc that I inherited
>
> nmap ,gs :.s/\\(.\\)/\\1 /g<CR>
> vmap ,gs :s/\\(.\\)/\\1 /g<CR>
I think I know what this is *supposed* to do... but I don't think that
this does it :-)
The 'nmap' rule is trying to convert a document of the form "abcd" to
"a b c d". That is, replace every character with that character and a
space. The 'vmap' rule does the same thing but only applies to the
visually selected text, not the whole document. Both actions are
activated when you type ',gs'
This is what it should like:
nmap ,gs :.s/\(.\)/\1 /g<CR>
vmap ,gs :s/\(.\)/\1 /g<CR>
Maps work in the form "map lhs rhs" where whatever you type in lhs is
replaced by whatever expression is in rhs. This expression is parsed
(roughly) like so:
:s apply to the entire document or selection
/\(.\) match any single character (the '.') and remember which one it
was (the parentheses)
/\1 / replace with the saved character (the \1) and a space
/g apply to the entire line, not just the first instance on a
line
--
Kurt Granroth | http://www.granroth.org
KDE Developer/Evangelist | SuSE Labs Open Source Developer
granroth@kde.org | granroth@suse.com
KDE -- Conquer Your Desktop