It takes lots of practicing and you must have a spanish (nylon strings) guitar to do it ... I've tried it with elec & acoustic (steel strings) guitars and it was very hard and sloppy... It's due to the more string spacing in spanish guitars.
Bass players use similar techniques to shred too.