When musicians use the word 'comping' they mean accompanying. It is especially common as a term in jazz and blues. In that context, 'comping' is what the other instruments, especially piano, guitar, bass and drums do when a solo is being played. They are providing the support, or accompaniment for the solo.
Why can't I just play the music as it is written?
Comping is what musicians will do when they are only provided with basic information, for example the style of the music and the chord symbols. Comping (as opposed to 'playing an accompaniment' which is more likely fully notated) contains, therefore, an element of improvisation.
So how do I do it?
We will concentrate mainly on the piano/keyboard, though the same principles apply to the guitar (and, to a lesser extent, the bass guitar and drums).
In situations in which you need to comp you will often be presented with a lead sheet, containing just chords and melody:
W C Handy - St Louis Blues sheet music for Keyboard.
Sometimes you will have to use your own musical knowledge to work out the style of a piece, but in this case the inclusion of the word 'blues' in the title gives us a hint that it should be performed with a relaxed swing. We also have the melody and chords.
You could, of course, play the melody of this piece on the piano with simple block chords in the left hand…
...though it will not sound very interesting.
True comping requires we give the left hand a bit of rhythm, even breaking out into the occasional melodic interjection (e.g. fourth bar):
On other occasions a solo instrument will be playing the melody, in which case the piano right hand will normally take the chords, the left hand providing a bass line:
In the same way other instruments can work out their own comping to fit round the melody. When doing it as an ensemble, it will require mutual understanding between the players so that they agree on style and do not individually overcomplicate the texture. A good group might sound something like this (remember, all of this will be based just on a simple lead sheet, the musicians improvising the accompaniment):
Whilst 'comping', as said, is mostly associated with jazz, the same principles apply when playing any lead sheet. For example, if a pianist were given this lead sheet:
Tchaikovsky - Waltz from Sleeping Beauty sheet music for Keyboard.
...they could just play it using block chords...
...however, an experienced player would know that a waltz is often played with an 'um-cha' accompaniment, so he or she would play something like this:
So how can I know what style to play in?
It is true that this is one of the most difficult aspects of comping well. When looking at a new piece, listen to other performances of it first. Use that to inspire your own performance. Little by little you will find that you will develop a feel for what style suits any particular piece.