If we look at the mwe you provided (pasted) in its native state we can see it is part of a web page and would need some serious decoding to restore it as you intended it to look.
<pre class="lang-tex prettyprint prettyprinted"><code><span class="kwd">\documentclass</span><span class="pun">{</span><span class="pln">article</span><span class="pun">}</span><span class="pln">
</span><span class="com">%some packages or newcommand I need to import </span><span class="pln">
</span><span class="kwd">\begin</span><span class="pun">{</span><span class="pln">document</span><span class="pun">}</span><span class="pln">
</span><span class="com">%I can directly copy some answers in tex.stackexchange</span><span class="pln">
</span><span class="kwd">\end</span><span class="pun">{</span><span class="pln">document</span><span class="pun">}</span><span class="pln"> </span></code></pre>
However if we simply cut and paste as plain text to ANY editor from simple notepad to the most complex of systems then it will be compatible, compliable and compilable
\documentclass{article}
%some packages or newcommand I need to
import
\begin{document}
%I can directly copy some answers in tex.stackexchange
Hello maplemaple
\end{document}
\pretend this is latex {class}
It may not be immediately apparent that in most browsers if you
double click the start or end of a structured code block like this
it will be possible to copy to clipboard, try me at start \ or here >
So there is generally no need to alter / decode answers for use in your editor other than any related comments to a correct answer, assuming you know it is correct :-)
For wider discussions on how's and why's you could look at Feature request: Better support for copying code from question or answers and the related links at the side of that discussion.