Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to write a beautify CSS command in vim that sorts and alphabetizes all of the CSS properties as well as checks to see if there is not a space after the colon and inserts one.

Here is my code:

nnoremap <leader>S :g#\({\n\)\@<=#.,/}/sort | %s/:\(\S\)/: \1/g<CR>
:command! SortCSSBraceContents :g#\({\n\)\@<=#.,/}/sort | %s/:\(\S\)/: \1/g              

These work independently. However, I am trying to pipe them into one command.

On save VIM says:

Error detected while processing /var/home/jesse-atkinson/.vimrc:
line  196:
E488: Trailing characters

Any ideas?

share|improve this question
There are about 30 trailing spaces at the end of your :command! line. – Excellll Oct 12 '12 at 15:37
Bad copy & paste job. I promise you that in my .vimrc there isn't. And it pukes on the line above, not the line with the command in it. – Jesse Atkinson Oct 12 '12 at 15:52
I suspect that <CR> is not supposed to be there. – Michael Hampton Oct 12 '12 at 17:21
@JesseAtkinson, it is not easy to find line 196 in your two lines example. – romainl Oct 12 '12 at 18:31
Line 196 is the first line I posted. – Jesse Atkinson Oct 18 '12 at 14:51
up vote 7 down vote accepted

You need to replace your | characters in that line with <bar>.

What's happening is that Vim is executing that line as separate commands rather than creating a mapping from the whole line.

See: :help map_bar

share|improve this answer
Thank you so much. This is now my new favorite and most useful VIM command. – Jesse Atkinson Oct 13 '12 at 0:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.