:set noautoindent
:set nosmartindent
vi,vimで編集時に、前の行のインデントをそのまま引き継いでくれる便利な設定があります。
それが autoindent です。
これ、コードを書いている時にはとても便利なんですけど、別のところからクリップボードにコピーしたコードを貼り付ける時は、インデントが二重になってしまって困ったことになります。
そんなときは、
でautoindentをオフにします。
でも、なぜかnoautoindentが効かない!という時があります。いや、僕の場合そんな場合のほうが多くて、諦めてダウンロードして別のエディタで開いたりしていたんですけど、最近ようやく気付きました。
vi,vimのインデントには、autoindentとsmartindentという二つのインデントスタイルがあったんですね。
というわけで、smartindentを解除したいときは
でOK。
コピペしたらこうなってしまっていたものが…
</div>                                                                                                                       
<script type="text/javascript">
  var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-99999999-1']);
      _gaq.push(['_trackPageview']);
        (function() {
                    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                              })();
                              </script>
</body>
</html>
綺麗に貼り付けられるようになりました。めでたし。
</div>
</div>                                                                                                                       
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-99999999-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
</body>                                                                                                                      
</html> 
ちなみに、今どんな環境がセッティングされているかは、
:set
で一覧表示させることができます。
また、毎回noautoindentをするようでしたら、.vimrcでデフォルトの設定を変更したほうがいいでしょう。