Suppose that L is a nonempty language over A, $$k\in \mathbb {N}^0$$ and $$m\in \mathbb {N}$$ . If L satisfies $$(LA^k)^mL$$ $$\cap A^+(LA^k)^{m-1}LA^+=\emptyset $$ , then L is a code and is called a (k, m)-comma code. If L is a (k, m)-comma code, then it is known that L is an infix code when $$m=1$$ and L is a bifix code when $$m\ge 1$$ . In this paper, we extend the study and find that the class of (k, m)-comma codes and the class of infix codes are incomparable but they are not disjoint, so we first characterize the (k, m)-comma codes with $$m\ge 2$$ which are infix codes. We also describe the solid codes with minimum lengths greater than k and the 2-(k, 1)-comma codes by different approaches. Finally, the class of bifix codes will be classified into disjoint union of some subclasses and a criterion to determine the subclass membership of a given bifix code will be given.