Box selection in Visual Studio

I was editing a large SQL script inside Visual Studio today and needed to insert several spaces into multiple lines to make the script more readable.

Turning something like this:

some text on line a
some text on line b
some text on line c
some text on line d

into:

some text      on line a
some text      on line b
some text      on line c
some text      on line d

I thought of doing it manually by hand, but as there were lots of lines to alter, I thought there must be a better way. I then remembered a feature of a word processor called ProText that I had many years ago on the Atari ST that had a feature called “Box Selection”. This enabled you to select text across multiple lines without having to select the whole line (a bit like drawing a box with the mouse).

A quick search later and I found the instructions on how to do box selections in Visual Studio in an article on Sara Ford’s blog.

Just hold down the Alt key whilst selecting text with the mouse and Visual Studio will switch from its normal “stream selection” mode into “box selection” mode. Once selected, you can indent the text using the tab key as normal and it will insert space to get the desired effect.


Blinking cursor in Firefox

I have recently re-installed Firefox, and was getting more and more annoyed by what seemed to be a blinking cursor appearing in web pages. After a bit of searching, I found out what it was thanks to Rishi who has had the same problem.

It is a feature called “Caret Browsing” which places a cursor in web pages so that text can be selected using only the keyboard. To turn the feature off, just press the F7 key or change the accessibility.browsewithcaret option from the about:config page.


Building solutions without Visual Studio

When working with several source control branches, especially with a large solution with many projects, it is not always practical to open Visual Studio to perform a quick build. Using NAnt is one alternative solution, but this requires creating and maintaining a build script. Using MSBuild from the command line is another option, but this involves getting the command line arguments correct, and working with command line output is not easy to visually filter. The same goes for using Visual Studio from the command line.

Gaston Milano has created a simple tool called Build Console capable of loading both MSBuild and Visual Studio solution files, and building any of the available build targets.

Build console

It’s main features are:

  • The ability to choose which target/project to build.
  • A build report in a tree structure to show the status of each project built.
  • The ability to choose the verbosity of the build output.
  • A coloured build output log to distinguish different types out log output.
  • A ‘quick history’ to load recently built solutions.

Whilst a little rough around the edges, it comes in very handy for those times where you just need to compile quickly without the overhead of loading Visual Studio.


Browser toolbars for web development

I’ve been doing a lot of HTML and CSS recently, and checking that pages appear and behave the same in different browsers can be a bit of a pain. Fortunatley, there are several toolbars that can be used to make this process easier.

Internet Explorer

  • Developer Toolbar
    This is a toolbar for Internet Explorer versions 6 and 7 that adds a DOM and CSS explorer and editor, as well as tools for viewing pages structures and various type of validation.

  • Web Development Helper
    This is similar to the Developer Toolbar above, but geared more for ASP.Net. It features several browsers for view state, caches, header and response details and call stacks, as well as a DOM explorer.

Firefox

  • Firebug (also here)
    This is an extension that adds a CSS, HTML, Javascript and DOM monitor and editor to the browser, as well as a request monitor and a element inspector.

  • Web Developer Toolbar (also here)
    This is a toolbar that adds lots of utilities and tools, including validation and page information and outlining.

  • HTML Validator (also here)
    This is an extension that adds an HTML validator to the browser that validates pages in real time and displays warnings and errors in the page status bar.

  • Dust-Me Selectors
    This is an extension that enables you to inspect CSS style sheets for selectors and styles that are loaded but not used when browsing pages. Useful for consolidating style sheets after a site redesign. NOTE: this didn’t install properly using the xpi file, but worked following a manual install.

  • Modify Headers (also here)
    This is an extension that enables the viewing and modification of HTTP headers.

  • User Agent Switcher (also here)
    This is an extension that allows the configuration of custom user-agent strings and enables switching them whilst browsing.

  • IE Tab (also here)
    This is an extension that allows the viewing of pages using the Internet Explorer rendering engine, but within the Firefox application.

  • IE View
    This extension is similar to the IE Tab extension above, but will open Internet Explorer as a separate window instead of embedding it inside FireFox.

  • IE View Lite (also here)
    This extension is a rewrite of the IE View extension above, but written to be more compact and lightweight.

  • Opera View (also here)
    This extension is similar to the IE View extension above, but will open pages in Opera instead of Internet Explorer.

Opera

  • Web Development Toolbar & Menu
    This toolbar and menu set add a set of menus and a toolbar. The menus contain quick links directlry to HTML, CSS, DOM, JS and Unicode reference information. The toolbar adds tools for inspecting page contents, validation, page source viewers and form manipulation.

  • Opera Developer Console
    This tool adds a button onto a toolbar that when clicked opens a windows containing a DOM, JS, CSS and HTTP browser for the current page.


Fixing database logins after a restore

For several years now I’ve been moving development databases between SQL Servers using backup and restore. When you restore the database on the target server, the logins for the database are invariably broken with the database user having an empty login name, meaning that they cannot log in to the database. My usual fix is to delete the database user and re-add it. Paul Hayman however pointed out a useful stored procedure to fix broken logins:

sp_change_users_login 'Auto_Fix', 'username'

where username is the name of the account to fix.

The Auto_Fix option will attempt to match the broken login with an existing user with the same name.

More information on this can be found in the MSDN documentation. Specific things to note are that it only works with SQL Server and not Windows logins, and that you must be a member of the sysadmin fixed server role for it to work.