Based on your other question I assume that you have the following set-up:
\documentclass{article}
\usepackage{unicode-math}
\setmainfont{Latin Modern Math}
\setmainfont{Latin Modern Roman}
And you want to replace any single character inside the macro \hat{...} by something like \hat{\symbfit{...}}.
As was noted in the comments, redefining existing macros may result in problems in the future, so I'd rather propose that you change your code.
This can be done, without the need to go through the code manually, by using a replaceemnt with regular expressions which, as far as I know, is supported by TeXstudio or Texmaker. Please consult the manual of the software about how exactly to use this.
The regular expression, that you could use to replace all (!) occurences of \hat{<one letter>} by \hat{\symbfit{<one letter>}} would be
Search pattern: \\hat\{([a-zA-Z])\}
Replacement pattern: \hat{\symbfit{$1}}
Note: Please consult the manual of the software, because the replacement pattern may be different. Some software uses \1 instead of $1 to select the first capture group of the search pattern, and sometimes you need to escape \ using \\ in the replacement pattern as well.
\hats at once. You don't have to go through your code manually then, – Jasper Habicht Apr 01 '21 at 12:37\hatwith\myhat. Then, define\myhatin your preamble in terms of\hatand you should be good to go (unless you have other document macros named\hathawayor something beginning with\hat). – Steven B. Segletes Apr 01 '21 at 12:50