R.Tanaka.Ichiro's Blog

主にC# な話題です

目次

Blog 利用状況

ニュース

コードスニペットが何気に便利すぎる件

以前は、自作して使っていたのですが面倒くさくなって、最近ではテケテケとキーボードでタイプしてました。

・・・が、予め用意されている

コードスニペットも、結構便利だな~

と最近改めて思ったのが、もり ひろゆきさんに教えていただいたpropdp。

コードスニペット自体、まだ試したことがない人は、使って見ると良いです。
試しに、VS のコードエディタを開いて、propa と入力語にタブキーを押してみて下さい。

これが発端で、最近は、思い浮かぶキーワードを入力後にインテリセンスを広げて、コードスニペットを探して使う毎日です。

もし、皆さんが普段使っていて便利だと感じる既存のコードスニペットがあったら教えて下さい~

投稿日時 : 2009年6月25日 11:26

Feedback

# re: コードスニペットが何気に便利すぎる件 2009/06/25 11:35 R・田中一郎

でも多用するとコードが書けなくなっちゃうんだよねw

# re: コードスニペットが何気に便利すぎる件 2009/06/25 14:00 T.Hirase

既存のでいえば「switch」ですね。
enum の列挙子をコピペしなくなりました。


自分で追加もできるのが良いですよね。。
・INotifyPropertyChanged実装スニペット
・関数の引数チェックスニペット
とか、便利、便利。

# re: コードスニペットが何気に便利すぎる件 2009/06/25 14:34 かるあ

VS2010 だと、ASPX のコードビューでもコードスニペットが使えるようになりましたね。
smp → ScriptManager
とか

# re: コードスニペットが何気に便利すぎる件 2009/06/25 21:24 Gushwell

ちょとした確認コードを書くときは cw ですね。

# re: コードスニペットが何気に便利すぎる件 2009/06/26 13:11 R・田中一郎

T.Hirase さん

>既存のでいえば「switch」ですね。
>enum の列挙子をコピペしなくなりました。

switch を使う機会があまりなかったので、気が付きませんでした。
enum の列挙をコピペしなくなったのはどうしてですか?

>自分で追加もできるのが良いですよね。。

以前は自作していたのですが、最近は、ゴリゴリ書いちゃってますねー

------------------------------
かるあ さん

>VS2010 だと、ASPX のコードビューでもコードスニペットが使えるようになりましたね。

ASPX のコードビューでも使えるんですね。
VS2010 は楽しみです。

------------------------------
Gushwell さん

>ちょとした確認コードを書くときは cw ですね。

これは、僕にとってかなり便利ですね!
Console.WriteLine は良く使うのです。

# re: コードスニペットが何気に便利すぎる件 2009/06/26 22:44 T.Hirase

switch のスニペットは、switch + 列挙体の変数 + TAB で列挙体に定義してある列挙子をcase文でならべてくれます。
下記のコードだと、sw + TAB + hoge + TAB + TAB くらいで入力できます。

switch (hogeEnumValue)
{
case HogeDayo:
break;
case HogeDesu:
break;
case HogePiyo:
break;
default:
break;
}

わざわざ、HogeDayo, HogeDesu, HogePiyo を定義からコピペして、case 書いて、、みたいなことをやらなくて済みます。

# re: コードスニペットが何気に便利すぎる件 2009/06/27 10:23 まりり

>T.Hiraseさん
switchのスニペットは「enumのときはdefaultいらないのにー」と思ってもやもやすることはあります。

>R・田中一郎さん
ご存知かもしれませんが、スニペットの本体は以下にあります。
1ファイル=1スニペットなので、何があるのか確認したいときには探しやすいです。
標準のスニペットが気に入らない、ということであれば変えてしまうこともできます。
C:\Program Files\Microsoft Visual Studio 9.0\VC#\Snippets\1041\Visual C#

# re: コードスニペットが何気に便利すぎる件 2009/06/30 10:15 R・田中一郎

T.Hirase さん

>switch のスニペットは、switch + 列挙体の変数 + TAB で列挙体に定義してある列挙子をcase文でならべてくれます。

なるほど、それは賢いですね。
列挙型や switch case 文を使う機会があったら試してみたいと思います。

--------------------------
まりり さん

>ご存知かもしれませんが、スニペットの本体は以下にあります。

以前ざっと眺めたことはありますが、既存の物ってあまり多くないんですよね。

コードスニペット自身は、.NET を使い始めた時に自作したものを多用していたのですが、作るのも管理するのも面倒になってやめてしまいました。

# You have made some decent points there. I checked on the internet to learn more about the issue and found most people will go along with your views on this site. 2018/10/05 7:50 You have made some decent points there. I checked

You have made some decent points there. I checked on the
internet to learn more about the issue and found most people will go along with your views on this
site.

# Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your weblog? My blog site is in the very same area of interest as yours and my visitors would definitely benefit from a lot of the information you present he 2018/10/06 13:12 Do you mind if I quote a couple of your articles a

Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your weblog?
My blog site is in the very same area of interest as yours and my visitors would definitely benefit from a lot of the information you
present here. Please let me know if this ok with you. Many thanks!

# Hi there friends, how is all, and what you wish for to say about this post, in my view its in fact awesome designed for me. 2018/10/18 20:32 Hi there friends, how is all, and what you wish fo

Hi there friends, how is all, and what you wish for to say about this post, in my view its in fact
awesome designed for me.

# Excellent beat ! I wish to apprentice even as you amend your website, how can i subscribe for a blog site? The account helped me a applicable deal. I had been a little bit acquainted of this your broadcast offered vibrant transparent idea 2018/11/04 20:15 Excellent beat ! I wish to apprentice even as you

Excellent beat ! I wish to apprentice even as
you amend your website, how can i subscribe
for a blog site? The account helped me a applicable deal. I had been a little bit acquainted
of this your broadcast offered vibrant transparent idea

# I am extremely impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you customize it yourself? Anyway keep up the excellent quality writing, it is rare to see a great blog like this one nowadays. 2018/11/14 20:30 I am extremely impressed with your writing skills

I am extremely impressed with your writing skills and
also with the layout on your weblog. Is this a paid theme or did you customize it yourself?
Anyway keep up the excellent quality writing,
it is rare to see a great blog like this one
nowadays.

# Sling tv coupons and promo codes for november 2018 I'd like to find out more? I'd love to find out some additional information. Sling tv coupons and promo codes for november 2018 2018/11/17 8:19 Sling tv coupons and promo codes for november 2018

Sling tv coupons and promo codes for november 2018
I'd like to find out more? I'd love to find out some additional information. Sling tv
coupons and promo codes for november 2018

# Hello there, You've done an excellent job. I'll definitely digg it and personally suggest to my friends. I am sure they will be benefited from this web site. 2018/11/18 2:31 Hello there, You've done an excellent job. I'll

Hello there, You've done an excellent job. I'll definitely digg
it and personally suggest to my friends. I am sure they will be benefited from this web site.

タイトル
名前
Url
コメント