For some reason, the following map is not working:
nmap ,u :.g/./t.|s/./=/g<CR>
It was intended that once I typed ,u on a line like this:
lorem ipsum
It should transform into:
lorem ipsum
===========
The result: I see :.g/./t. in the bottom of the window. Then I tried escaping the |, and now once I use the mapping I simply see :.g/./t.|s/./=/g in the bottom, and nothing happens.
There probably is a better and error-free way to do it, I still a beginner.
Thanks!
You need to escape bar in mapping: either use
\|, or<bar>. Now it is parsed as two commands:nmap ,u :.g/./t.ands/./=/g<CR>.And do not use
nmap, usennoremap.Update: though escaped variant of your mapping works, I would have written it as either
yyp:s/./=/g<CR>, as:call append('.', repeat('=', strdisplaywidth(getline('.'))))<CR>(vim-7.3, best variant) or as:call append('.', repeat('=', len(split(getline('.'), '\zs'))))<CR>(vim-7.2, has just the same problems with tabs and fullwidth characters asyyp...variant, but does not overwrite any registers).