Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 116113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:07:36+00:00 2026-05-11T03:07:36+00:00

What is the easiest way to programmatically force capitalization of keywords in Visual Studio

  • 0

What is the easiest way to programmatically force capitalization of keywords in Visual Studio 2008?

We work with a proprietary command delimited language (like HTML). We are attempting to migrate from an older editor to Visual Studio 2008. Our coding standards are to capitalize the commands. The old editor is customized to recognize the command begin delimiter and to force capitalization until the end delimiter is typed or the escape key is pressed.

What’s the best way to do that in Visual Studio 2008? Can it be done with a macro or an add-in?

(Edited 1-12-2009)

Thank you for the suggestions so far. I don’t think they answer my question.

Clarifications:

  • The previous editor was CodeWright so the customizations there are not portable to visual studio.
  • The source code is not C#. StyleCop seems to be specifically for C#. Our language is similar to markup languages like HTML but with different delimiter characters and commands.
  • I am trying to actually capitalize as the developer types, not remind them about proper capitalization. Since the commands are all delimited our current editor actually turns the Caps Lock on when the beginning delimiter is typed. When the end delimiter or the escape key is pressed the caps lock is turned back off. This is independent of the state of the Caps Lock on the keyboard.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:07:36+00:00Added an answer on May 11, 2026 at 3:07 am

    This may not be the best solution but here is what I came up with.

    Use macros to capture Key Press Events.

    Here’s how:

    1. In Visual Studio go to the Tools->Macros->Macros IDE menu
    2. Double Click ‘MyMacros’ to see the different parts
    3. Double Click ‘EnvironmentEvents’
    4. Add the following code within the Environment Events module.
    5. Save the file and return to the regular VS IDE to test.

      Private My_AutoCaps As Boolean = False Private Sub TextDocumentKeyPressEvents_BeforeKeyPress(ByVal Keypress _   As String, ByVal Selection As EnvDTE.TextSelection, _   ByVal InStatementCompletion As Boolean, ByRef CancelKeyPress As Boolean) _   Handles TextDocumentKeyPressEvents.BeforeKeyPress      Dim fileName As String = UCase(Selection.DTE.ActiveDocument.Name)      If ( fileName.EndsWith('.CPI') ) Then          If (My_AutoCaps) Then              'MsgBox(Keypress)              If (Keypress = '(' Or Keypress = ':') Then                  'MsgBox('End of command character pressed.')                  My_AutoCaps = False                  Return              ElseIf (Keypress >= 'a' And Keypress <= 'z') Then                  'MsgBox('Letter pressed.')                  Selection.Text = UCase(Keypress)                  CancelKeyPress = True              End If          Else 'AutoCap is not on yet              If (Keypress = '^') Then                  'MsgBox('You pressed the Start Command character.')                  My_AutoCaps = True                  Return              End If          End If      End If End Sub 

    This macro is limited to *.CPI files.

    I have not figured out how to capture the Esc key yet but this will work for now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whats the easiest way to copy a visual studio project between distinct solutions? can
What is the easiest way to programmatically find the current toggle state of a
What's the easiest way to programmatically darken a hex colour?
What is the easiest way to programmatically extract structured data from a bunch of
What's the easiest way to find out if two text files are different programmatically?
I'm looking for the best/easiest way to programmatically grab the name of the US
What is the easiest way to programatically convert a compressed wav file (MPEG codec
The easiest way to think of my question is to think of a single,
What would be the easiest way to separate the directory name from the file
In TFS whats the easiest way of linking a backlog item to a large

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.