{"id":2302,"date":"2015-09-15T07:57:46","date_gmt":"2015-09-15T07:57:46","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=2302"},"modified":"2015-09-15T07:57:46","modified_gmt":"2015-09-15T07:57:46","slug":"visual-studio-edit-menu-tips-tricks","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2015\/09\/15\/visual-studio-edit-menu-tips-tricks\/","title":{"rendered":"Visual Studio &#8211; Edit Menu Tips &#038; Tricks"},"content":{"rendered":"<p>For those who use Visual Studio (VS) on a regular basis, they know that VS has hundreds of options and features but most people only use a small subset of them on a regular basis. It is always wise to know and explore all the capabilities of your IDE, because they could save you a lot of time and trouble and make you more productive.<\/p>\n<p>Here we are going to look at some interesting options which are available under the Edit Menu, specifically:<\/p>\n<ol>\n<li>Cycle Clipboard Ring<\/li>\n<li>Paste Special<\/li>\n<li>Insert File As Text<\/li>\n<\/ol>\n<h4>Cycle Clipboard Ring<\/h4>\n<p>Normally when you do Ctrl-C and Ctrl-V multiple times, whatever data you copied last is what is pasted. So for instance, if you have three lines of code:<\/p>\n<pre>int x = 0\r\nint y = 0\r\nint z = 0\r\n<\/pre>\n<p>If you copy each line separately starting from x to y, then when you press Ctrl-V you will get <em>int z=0<\/em><\/p>\n<p>But if you press Ctrl-Shift-V successively then it will cycle through the three lines in the clipboard and you can choose which one to paste.<\/p>\n<p>So pressing Ctrl-Shift-V once, we get <em>int z = 0. <\/em><\/p>\n<p>Pressing it again, we get <em>int y = 0<\/em><\/p>\n<p>Pressing it again we get <em>int x = 0<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>Paste Special<\/h4>\n<p>Paste Special has two suboptions:<\/p>\n<ol>\n<li>Paste JSON as Classes<\/li>\n<li>Paste XML as Classes<\/li>\n<\/ol>\n<p>This is a very useful tool to have, as it automatically converts a JSON string or an XML string copied into the clipboard into relevant C# classes with the correct methods and attributes.<\/p>\n<p>Here is an example of JSON conversion:<\/p>\n<pre>[\r\n\t{\r\n\t\tcolor: \"red\",\r\n\t\tvalue: \"#f00\"\r\n\t},\r\n\t{\r\n\t\tcolor: \"green\",\r\n\t\tvalue: \"#0f0\"\r\n\t},\r\n\t{\r\n\t\tcolor: \"blue\",\r\n\t\tvalue: \"#00f\"\r\n\t},\r\n\t{\r\n\t\tcolor: \"cyan\",\r\n\t\tvalue: \"#0ff\"\r\n\t},\r\n\t{\r\n\t\tcolor: \"magenta\",\r\n\t\tvalue: \"#f0f\"\r\n\t},\r\n\t{\r\n\t\tcolor: \"yellow\",\r\n\t\tvalue: \"#ff0\"\r\n\t},\r\n\t{\r\n\t\tcolor: \"black\",\r\n\t\tvalue: \"#000\"\r\n\t}\r\n]\r\n\r\n<\/pre>\n<p>When you do a Paste Special with the above data, it becomes:<\/p>\n<pre>public class Rootobject\r\n{\r\npublic Class1[] Property1 { get; set; }\r\n}\r\n\r\npublic class Class1\r\n{\r\npublic string color { get; set; }\r\npublic string value { get; set; }\r\n}\r\n\r\n<\/pre>\n<p>Here is an example of XML conversion:<\/p>\n<p><a href=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2015\/09\/XML-File-for-the-Complex-Data-Example-2015-09-15-13-22-34.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-2306\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2015\/09\/XML-File-for-the-Complex-Data-Example-2015-09-15-13-22-34-620x602.png\" alt=\"XML File for the Complex Data Example 2015-09-15 13-22-34\" width=\"620\" height=\"602\" srcset=\"https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2015\/09\/XML-File-for-the-Complex-Data-Example-2015-09-15-13-22-34-620x602.png 620w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2015\/09\/XML-File-for-the-Complex-Data-Example-2015-09-15-13-22-34-300x291.png 300w, https:\/\/truelogic.org\/wordpress\/wp-content\/uploads\/2015\/09\/XML-File-for-the-Complex-Data-Example-2015-09-15-13-22-34.png 696w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>When you do a Paste Special with the above data, it becomes:<\/p>\n<pre>\/\/\/ \r\n    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]\r\n    [System.Xml.Serialization.XmlRootAttribute(Namespace = \"\", IsNullable = false)]\r\n    public partial class catalog\r\n    {\r\n\r\n        private catalogProduct productField;\r\n\r\n        \/\/\/ \r\n        public catalogProduct product\r\n        {\r\n            get\r\n            {\r\n                return this.productField;\r\n            }\r\n            set\r\n            {\r\n                this.productField = value;\r\n            }\r\n        }\r\n    }\r\n\r\n    \/\/\/ \r\n    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]\r\n    public partial class catalogProduct\r\n    {\r\n\r\n        private catalogProductCatalog_item[] catalog_itemField;\r\n\r\n        private string descriptionField;\r\n\r\n        private string product_imageField;\r\n\r\n        \/\/\/ \r\n        [System.Xml.Serialization.XmlElementAttribute(\"catalog_item\")]\r\n        public catalogProductCatalog_item[] catalog_item\r\n        {\r\n            get\r\n            {\r\n                return this.catalog_itemField;\r\n            }\r\n            set\r\n            {\r\n                this.catalog_itemField = value;\r\n            }\r\n        }\r\n\r\n        \/\/\/ \r\n        [System.Xml.Serialization.XmlAttributeAttribute()]\r\n        public string description\r\n        {\r\n            get\r\n            {\r\n                return this.descriptionField;\r\n            }\r\n            set\r\n            {\r\n                this.descriptionField = value;\r\n            }\r\n        }\r\n\r\n        \/\/\/ \r\n        [System.Xml.Serialization.XmlAttributeAttribute()]\r\n        public string product_image\r\n        {\r\n            get\r\n            {\r\n                return this.product_imageField;\r\n            }\r\n            set\r\n            {\r\n                this.product_imageField = value;\r\n            }\r\n        }\r\n    }\r\n\r\n    \/\/\/ \r\n    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]\r\n    public partial class catalogProductCatalog_item\r\n    {\r\n\r\n        private string item_numberField;\r\n\r\n        private decimal priceField;\r\n\r\n        private catalogProductCatalog_itemSize[] sizeField;\r\n\r\n        private string genderField;\r\n\r\n        \/\/\/ \r\n        public string item_number\r\n        {\r\n            get\r\n            {\r\n                return this.item_numberField;\r\n            }\r\n            set\r\n            {\r\n                this.item_numberField = value;\r\n            }\r\n        }\r\n\r\n        \/\/\/ \r\n        public decimal price\r\n        {\r\n            get\r\n            {\r\n                return this.priceField;\r\n            }\r\n            set\r\n            {\r\n                this.priceField = value;\r\n            }\r\n        }\r\n\r\n        \/\/\/ \r\n        [System.Xml.Serialization.XmlElementAttribute(\"size\")]\r\n        public catalogProductCatalog_itemSize[] size\r\n        {\r\n            get\r\n            {\r\n                return this.sizeField;\r\n            }\r\n            set\r\n            {\r\n                this.sizeField = value;\r\n            }\r\n        }\r\n\r\n        \/\/\/ \r\n        [System.Xml.Serialization.XmlAttributeAttribute()]\r\n        public string gender\r\n        {\r\n            get\r\n            {\r\n                return this.genderField;\r\n            }\r\n            set\r\n            {\r\n                this.genderField = value;\r\n            }\r\n        }\r\n    }\r\n\r\n    \/\/\/ \r\n    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]\r\n    public partial class catalogProductCatalog_itemSize\r\n    {\r\n\r\n        private catalogProductCatalog_itemSizeColor_swatch[] color_swatchField;\r\n\r\n        private string descriptionField;\r\n\r\n        \/\/\/ \r\n        [System.Xml.Serialization.XmlElementAttribute(\"color_swatch\")]\r\n        public catalogProductCatalog_itemSizeColor_swatch[] color_swatch\r\n        {\r\n            get\r\n            {\r\n                return this.color_swatchField;\r\n            }\r\n            set\r\n            {\r\n                this.color_swatchField = value;\r\n            }\r\n        }\r\n\r\n        \/\/\/ \r\n        [System.Xml.Serialization.XmlAttributeAttribute()]\r\n        public string description\r\n        {\r\n            get\r\n            {\r\n                return this.descriptionField;\r\n            }\r\n            set\r\n            {\r\n                this.descriptionField = value;\r\n            }\r\n        }\r\n    }\r\n\r\n    \/\/\/ \r\n    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]\r\n    public partial class catalogProductCatalog_itemSizeColor_swatch\r\n    {\r\n\r\n        private string imageField;\r\n\r\n        private string valueField;\r\n\r\n        \/\/\/ \r\n        [System.Xml.Serialization.XmlAttributeAttribute()]\r\n        public string image\r\n        {\r\n            get\r\n            {\r\n                return this.imageField;\r\n            }\r\n            set\r\n            {\r\n                this.imageField = value;\r\n            }\r\n        }\r\n\r\n        \/\/\/ \r\n        [System.Xml.Serialization.XmlTextAttribute()]\r\n        public string Value\r\n        {\r\n            get\r\n            {\r\n                return this.valueField;\r\n            }\r\n            set\r\n            {\r\n                this.valueField = value;\r\n            }\r\n        }\r\n    }\r\n\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h4>Insert File As Text<\/h4>\n<p>This option is self-explanatory. Instead of having to open a file with text data externally and manually copying and pasting the contents into your IDE, you can choose Insert File as Text, navigate to the file and click on it. The contents of the file will be automatically copied into your current cursor position.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>For those who use Visual Studio (VS) on a regular basis, they know that VS has hundreds of options and features but most people only <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2015\/09\/15\/visual-studio-edit-menu-tips-tricks\/\" title=\"Visual Studio &#8211; Edit Menu Tips &#038; Tricks\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":2308,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,15],"tags":[],"class_list":["post-2302","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-net","category-windows"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=2302"}],"version-history":[{"count":4,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2302\/revisions"}],"predecessor-version":[{"id":2307,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2302\/revisions\/2307"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/2308"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=2302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=2302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=2302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}