I found both Rstudio functions could reindent the code. so what is the difference?
Reindent only adjusts the leading spacing on each line; reformat is more aggressive and will also add/remove line breaks and spacing.