How to decide the best form of BMI used in cox regression, categorical or continuous? BMI is always analysed in the form of a categorical variable in medical research. In my Cox regression model, I kept BMI in its original form, i.e., a continuous variable. But the reviewer asked how I can be sure that continuous BMI fits better than categorical BMI. Therefore, I need to test the linearity of BMI. I divided BMI into four sections, but the HRs of BMI in four categories were not significant anymore, while the continuous BMI was statistically significant. Am I in the wrong direction? Are there any better methods to test the linearity of BMI?

BMI might be associated continuously with outcome but not necessarily linearly. The best way to test that is to fit BMI as a continuous predictor flexibly, for example with restricted cubic splines as in the rms package in R. If you use the tools in that package, then you can use its anova() function to test the significance of the continuous fit overall and of the non-linear terms in particular.
There is almost never anything to be gained by categorizing a continuous variable. If someone insists that you do it anyway, compare the Akaike Information Criteria (AIC) of the models fit continuously and with categorization. I suspect that the fit will be better with a flexibly fit continuous variable.
One question to consider is whether BMI, itself a derived variable, is useful. It's quite possible that fitting both its components, height and weight, would work better.
