This question already has an answer here:
I am an Indian citizen holding a valid residence permit for work from Sweden. I want to know how the 90/180 rule works for person holding a valid residence permit within a member state. Does this permit allow them to travel within other Schengen countries? If yes, then how can those 90 days be spent over 180 days? E.g. iIf I travel out from Sweden to another Schengen country only for 2 days, and returning back to Sweden (as per the rule, my stay inside Sweden on valid residence permit is not going to count) Does it mean that I was in Schengen only for 2 days? And I still have 88 days left? Is it possible to divide these 88 days over many trips within Schengen while returning back to Sweden after any short trip? Am I allowed to make my second trip after spending 2 months in Sweden as long as I'm not exceeding the 90 days limit?