Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts
Sunday, 17 February 2013

Select a file in solution explorer without previewing in Visual Studio 2012

Preview

One of the new features in VS2012 is the ability to 'preview' a file instead of opening it fully which will open it in the 'preview' pane (docked to the right). To do this Left click on the file in the solution explorer. The great thing about it is that you can only have one preview open at a time. So when you're searching for something looking through several files in the process, the ones that aren't needed will close themselves.

As cool as it is, it started to annoy me after a while as I click in the solution explorer to enable scrolling if I'm out of Visual Studio. If it happens to be a large file it can take a second or two to load. So I went looking for a solution and it didn't take long to find one. Alt + Left click in the solution explorer will not show a preview of the file.

Sunday, 3 February 2013

Go to active document in Visual Studio 2012 solution explorer

Finally! Visual Studio natively supports jumping to the active document in the solution explorer with Visual Studio 2012. The command is called "Sync with Active Document" and can be accessed from the Solution Explorer toolbar.

Go to active document in solution explorer

The default shortcut is Ctrl + [, S and can be customised by modifying the SolutionExplorer.SyncWithActiveDocument command in keyboard options (Tools -> Customise -> Keyboard)

Sync active document customise
Friday, 26 October 2012

Strongly-typed SQL scripts in a Visual Studio project

One way that I've used to grab SQL from a file in the past is to simply include the SQL as a string in a resource file. This isn't really ideal though if you plan to edit or even view your SQL again.

You can actually attach any type of text file to a resource file, which works just like a regular strings resource file, but you get to store the files wherever you like and in whatever format you like. Allowing you to take advantage of the SQL syntax highlighting and validation within the text editor and also ease-of-use and type safety of resource files.

Just follow follow these steps:
  1. Add your SQL file to your project
  2. Create a resource file, preferably with a name that indicated that it contains files
  3. Open the resource file and select 'Files' from the dropdown in the top-left corner (by default it opens on 'Strings')
  4. Click add resource then find and select the SQL file
  5. Save the resource file
You should now be able to access your SQL directly from the resource file in code.


This works in Visual Studio 2012 and 2010, not so sure about earlier versions.
Sunday, 22 April 2012

SASS: Syntactically Awesome Stylesheets

SASS stands for Syntactically Awesome Stylesheets, yes, I'm quite a fan of the name. It provides us with a much simpler and more elegant way of defining CSS, allowing the creation of more modular and manageable stylesheets. SASS has two flavours; SASS-style and SCSS-style, the basic difference being that SASS-style uses indentation to separate code-blocks instead of curly braces. The examples used in this post will be using the SCSS-style.

Several years ago, I was playing around with CSS thinking how great it would be if CSS was able to define variables. The help it would be just having the ability to define the colours of a site so you don't have random hex values peppered throughout your stylesheet would be huge. This problem is what instantly drew me to SASS.