viの編集時に自動的にインデントがネストされるのを停止する noautoindent, nosmartindent

このエントリーをはてなブックマークに追加
オートインデントを無効にする

:set noautoindent
:set nosmartindent

vi,vimで編集時に、前の行のインデントをそのまま引き継いでくれる便利な設定があります。
それが autoindent です。

これ、コードを書いている時にはとても便利なんですけど、別のところからクリップボードにコピーしたコードを貼り付ける時は、インデントが二重になってしまって困ったことになります。

そんなときは、

:set noautoindent

でautoindentをオフにします。

でも、なぜかnoautoindentが効かない!という時があります。いや、僕の場合そんな場合のほうが多くて、諦めてダウンロードして別のエディタで開いたりしていたんですけど、最近ようやく気付きました。

vi,vimのインデントには、autoindentとsmartindentという二つのインデントスタイルがあったんですね。

というわけで、smartindentを解除したいときは

:set nosmartindent

で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でデフォルトの設定を変更したほうがいいでしょう。

viの編集時に自動的にインデントがネストされるのを停止する noautoindent, nosmartindent」への180件のフィードバック

  1. check this site out

    I simply want to say I’m new to blogging and site-building and honestly enjoyed your page. More than likely I’m going to bookmark your site . You really have exceptional article content. Kudos for sharing with us your website.

    返信
  2. money tip

    Wonderful story, reckoned we could combine a couple of unrelated information, nonetheless seriously worth taking a search, whoa did a single learn about Mid East has got much more problerms too

    返信
  3. Nathaniel Farley

    The following time I read a blog, I hope that it doesnt disappoint me as a lot as this one. I mean, I do know it was my option to read, but I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you would fix should you werent too busy in search of attention.

    返信
  4. Lena

    Hmm is anyone else having problems with the pictures on this blog loading?

    I’m trying to determine if its a problem on my end or if it’s the blog.
    Any responses would be greatly appreciated.

    返信
  5. games

    Can I just say what a relief to uncover an individual who truly understands what
    they are talking about online. You actually realize how
    to bring an issue to light and make it important.
    More people need to read this and understand this side of
    your story. It’s surprising you are not more popular because you
    most certainly possess the gift.

    返信
  6. Keena

    I am looking both for blog sites that offer impartial, balanced commentary on all issues or blog sites that have a liberal or left-wing angle. Thanks.

    返信
  7. THE CAMERA GUYS

    Wonderful story, reckoned we could combine some unrelated information, nonetheless really really worth taking a appear, whoa did a single find out about Mid East has got additional problerms as well

    返信
  8. Todd Snively

    Hello, i read your blog occasionally and i own a similar one and i was just wondering if you get a lot of spam feedback? If so how do you prevent it, any plugin or anything you can suggest? I get so much lately it’s driving me mad so any assistance is very much appreciated.

    返信
  9. pheromones

    although sites we backlink to below are considerably not connected to ours, we really feel they are really really worth a go as a result of, so have a look

    返信
  10. Miss Martelli

    I must thank you for the efforts you have put in penning this website. I’m hoping to check out the same high-grade content from you in the future as well. In truth, your creative writing abilities has encouraged me to get my own site now ;)

    返信
  11. investors

    Wonderful story, reckoned we could combine some unrelated information, nevertheless really worth taking a search, whoa did one master about Mid East has got more problerms as well

    返信
  12. mehndi dresses

    Wonderful story, reckoned we could combine several unrelated information, nevertheless seriously worth taking a look, whoa did one master about Mid East has got extra problerms as well

    返信
  13. Wallace Bristle

    Hi folks here, just turned alert to your blogging site through Search engines like google, and realized that it’s truly informational. I’ll like should you persist this idea.

    返信
  14. Annamae Axel

    This is convenient occasion to get some schedules for the longer term. I’ve go through this article and if I can possibly, I want to propose you some enlightening tip.

    返信
  15. viagra

    very handful of internet websites that transpire to become comprehensive beneath, from our point of view are undoubtedly properly really worth checking out

    返信
  16. viagra

    Nice post. I learn something new and challenging on blogs I stumbleupon on a daily basis. It’s always useful to read through content from other authors and practice something from other sites.

    返信
  17. Eric Vanbelle

    It is the best day to produce some intentions for the longer term. I’ve read through this document and if I should, I desire to suggest to you you very few appealing advice.

    返信
  18. additional reading

    I just want to say I am all new to weblog and absolutely savored this web-site. Most likely I’m going to bookmark your site . You amazingly come with terrific articles and reviews. Thank you for revealing your blog site.

    返信
  19. viagra

    Greetings! Very helpful advice in this particular article! It’s the little changes that will make the most significant changes. Thanks for sharing!

    返信
  20. Terra Doulani

    It’s suitable time to put together some plans for the foreseeable future. I have digested this post and if I may possibly, I want to propose you very few important tip.

    返信
  21. Forest Adair

    Aw, this was an extremely good post. Spending some time and actual effort to create a superb article… but what can I say… I put things off a lot and never seem to get anything done.

    返信
  22. hotmail iniciar sesion

    Oh my goodness! Incredible article dude! Many thanks, However I am going through troubles with your RSS. I don’t understand the reason why I am unable to subscribe to it. Is there anybody having the same RSS issues? Anybody who knows the answer will you kindly respond? Thanks.

    返信
  23. The Path of Wisdom

    Aw, this was a really nice post. Taking a few minutes and actual effort to produce a great article… but what can I say… I hesitate a whole lot and don’t manage to get anything done.

    返信
  24. Google

    Wonderful story, reckoned we could combine a number of unrelated data, nevertheless definitely worth taking a look, whoa did 1 learn about Mid East has got extra problerms also.

    返信
  25. cbd

    very couple of sites that take place to become in depth beneath, from our point of view are undoubtedly nicely really worth checking out

    返信
  26. Fastandy

    May I simply just say what a comfort to discover an individual who truly knows what they are talking about over the internet. You certainly know how to bring an issue to light and make it important. More people must look at this and understand this side of your story. I was surprised you are not more popular because you most certainly possess the gift.

    返信
  27. Elle Blonde

    Your style is really unique compared to other people I have read stuff from. Thank you for posting when you’ve got the opportunity, Guess I will just bookmark this page.

    返信
  28. SEO

    although internet sites we backlink to beneath are considerably not associated to ours, we really feel they are essentially really worth a go by way of, so possess a look

    返信
  29. как составить вопросы по испории 6 класса гдз

    I’ve been exploring for a little for any high-quality articles or weblog posts in this kind of area . Exploring in Yahoo I eventually stumbled upon this web site. Reading this info So i’m happy to show that I’ve a very good uncanny feeling I came upon exactly what I needed. I so much surely will make sure to do not forget this web site and provides it a glance regularly.| а

    返信
  30. Best Massage Gun

    Hi there! This blog post could not be written much better! Reading through this post reminds me of my previous roommate! He constantly kept preaching about this. I will forward this post to him. Pretty sure he’s going to have a great read. Thank you for sharing!

    返信
  31. Correduria Publica en Cancun

    May I simply just say what a comfort to uncover an individual who really knows what they are talking about on the internet. You definitely understand how to bring an issue to light and make it important. More people have to look at this and understand this side of your story. I can’t believe you are not more popular given that you surely possess the gift.

    返信
  32. cbd oil

    Oh my goodness! Incredible article dude! Thanks, However I am going through difficulties with your RSS. I don’t understand the reason why I am unable to join it. Is there anybody getting similar RSS problems? Anyone that knows the answer will you kindly respond? Thanx!

    返信
  33. Lizabeth Bruins

    This is the right web site for anybody who really wants to find out about this topic. You realize so much its almost tough to argue with you (not that I really would want to…HaHa). You certainly put a fresh spin on a topic that’s been written about for decades. Wonderful stuff, just great.

    返信

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>