Q:

Visual mode mapping not working. Do I have to escape characters?

I have the following dysfunctional mapping
" Capitalise each word in selection
vmap gw :'<,'>s/\<./\u&/g<CR>

which should do what the comment says. But when I use it, vim reports E488: Trailing characters. It works when I leave out the selection marks '<,'>, but then it applies to the whole line.
I suspect I need to escape something here, but the help page only lists some other characters which must be escaped.

A:

When you enter command-line mode from visual mode Vim automatically populates the command-line with '<,'>. Your mapping adds another '<,'> after the automatic one which makes your command invalid.
This:
xnoremap gw :s/\<./\u&/g<CR>

does exactly what you'd expect.
--- edit ---
Substitutions are line-wise by default. If you want to restrict your substitution to the current visual selection you need to add the \%V atom to your search pattern:
xnoremap gw :s/\%V\<./\u&/g<CR>

See :help \%V.

