Disable Auto-Tab in Visual Studio via a dat file - visual-studio

I wrote a dat file for when I'm writing assembly to give me some syntax highlighting, the problem I am running into is that one way to do a comment in MASM is to use a semicolon and you typically tab a fair bit away from the actual code before you write the comment (at least I do). Well whenever I do this, it messes up all of the formatting in the .asm file because it tries to format the document whenever it sees a semicolon, I am wondering is there a way to turn off auto tabbing and other stuff via a dat file? I just know how to load a dat file that tells the editor some words to highlight, that's it.
Thanks in advance for any input on this :)

You can export the specific settings for a certain project and then import it later. This will save .vssettings XML format file.
Just define you tab setting before in Options dialog from the Tools menu, selecting the Text Editor -> Your prefered language-> Formatting -> General page, and unchecking relevant check- box ( in your case tabbing).
Then in Tools > Import and Export Settings , export the settings.
I hope it sort your issue.

Related

Tabs not being recognized from RStudio text editor

If I create a simple Makefile in an Rstudio Text File:
graphic1.jpeg : mouse.csv graphic1.R
Rscript graphic1.R
It will not execute. I get the error message, "Makefile:2: *** missing separator. Stop." because the tab in line 2 is not really a tab.
If I edit the Text File in Text Wrangler, a real tab will be inserted and the file will execute.
I have updated my RStudio Preferences / Code to ensure that the box is unchecked for "insert spaces for tab".
Is this just a bug in RStudio text editor?
If you want to change this setting temporarily e.g. to tabulate a Makefile or a .tsv file, the fastest way is to only change the Project Options, do your stuff, and then revert it back.
The project options take precedence over Global Options, so changing the global ones only makes sense if you want to keep that option enabled for all future projects.
So I just learned from an R-Bloggers post by Jeffrey Hollister that there are two places in RStudio where I need to uncheck "Insert spaces for tab":
1) RStudio / Preferences / Code
2) Tools / Project Options / Code Editing
I am now up and running.

Why does Visual Studio Code insert spaces when editing a Makefile and "editor.insertSpaces": "auto"?

make doesn't like spaces for the body of a target in a Makefile. Has to be a tab.
I changed "editor.insertSpaces" to "auto", thinking this would help. It didn't.
I had to set it to false in order to get the code working.
This is now possible with Language Specific Settings.
https://code.visualstudio.com/docs/getstarted/settings#_language-specific-editor-settings
To customize your editor by language, run the global command Preferences: Configure Language Specific Settings (command id: workbench.action.configureLanguageBasedSettings) from the Command Palette (⇧⌘P) which opens the language picker. Selecting the language you want, opens the Settings editor with the language entry where you can add applicable settings.
Once you have the editor open, enter the following configuration for [makefile]
{
"[makefile]": {
"editor.insertSpaces": false,
"editor.detectIndentation": false
}
}
VS Code does accurately guess the file type for a Makefile, but the language configuration does not specify tab style. There is an outstanding pull request that addresses this issue.
Before that PR lands, you may be able to fix this locally by editing the application itself. On OSX where applications are really just folders, you can find the language configuration for Makefiles in Visual Studio Code.app/Contents/Resources/app/extensions/make. Open up make.configuration.json and add "insertSpaces": false on line 2. That fixed it for me.
Visual Studio Code users that wish to use spaces as their indent character in the global configuration will have trouble editing Makefiles because it requires the user to use tabs as their indent character instead of spaces. Updating the configuration just to edit a few lines is not a viable solution IMO.
You can use the Command Palette (View > Command Palette) and type Convert Indentation to Tabs and hit Enter. You editor should now have updated all indentation to their corresponding tabs equivalent.

How do I record a Visual Studio macro to set Options settings?

I've just tried to record a macro to help me switch word-wrap in editors on and off quickly, but all the macro records is DTE.ExecuteCommand("Tools.Options"), which leaves me with a big, dumb open dialogue when I try and execute the macro.
How can I record or write macros to help me quickly set options, without the rudeness of the modal options dialogue? Are there any extensions I could use for this?
For a bonus point, is there a way I can automate Options changes without using macros, and without having to write a big VS extension?
switch word-wrap in editors on and off quickly
Maybe I'm confused, but word wrap is toggled by Ctrl-E, Ctrl-W.
is there a way I can automate Options changes without using macros
You can use the Visual Studio command window here:
View > Other Windows > Command Window
In addition to the Visual Studio Commands list, you can enter any Menu command in the command window. I found Edit.ToggleWordWrap, which toggles word wrap in the currently-focused text editor.
To bind a command (or several commands) to a shortcut key, create an Add-In (not a big VS extension ;). In your case, the relevant line would look like this:
cmd = cmds.Item("Edit.ToggleWordWrap", 1);
There's really no way to record a macro to set anything in the Options dialog. The macro recording infrastructure in general can't handle modal dialogs and essentially ignores them. The options dialog is no exception here.
The best hope here is to
Save the options out to a vssettings file
Hand code a macro which manipulates the low level IVs interfaces to set the options you want.
The vssettings file is the more viable, and far simpler, option

Can I enable the "Comment out the selected lines" feature for working on text files in Visual Studio?

Can I enable the "Comment out the selected lines" feature for working on text files in Visual Studio 2008 or 2010? I'd like the ability to use that function on files other than normal code related files. When I open a TXT file the comment and un-comment buttons are disabled. Is there a way to change that?
Thanks
Clarification: I use this text file to hold instructions for another program. Each Line holds one instruction. Sometimes I need to comment out blocks of instructions at a time. We use the "//" characters to accomplish this.
Could you give your filename a C++ extension (e.g., .h, .cpp) to fool the editor into thinking it's a C++ source file?
It appears you could also give it any extension and map that extension to a particular editor in: Options --> Text Editor --> File Extension
Unfortunately you cannot. The "Comment Out Selected" lines feature is a language specific feature and the text language service does not implement it (it's actually hard to call it a language service in general).
Besides what would commenting out a line in a text file look like? You could use Replace all + a regular expression to achieve the same thing though.
I'm curious what you would expect a commented line in a text file to do, or what it would look like. A commented line in a programming language causes that line not to be executed, but since a text file is just data, it doesn't execute anything anyway.

Copy-paste code from Visual Studio, but paste UNFORMATTED code

Is there any way to force Visual Studio to copy selected code to the clipboard as unformatted text?
When I am copy-pasting code into Word or more often Outlook I have to do it via Notepad to get rid of the formatting...there has to be an easier way!
This feature can be turned off by editor.copyWithSyntaxHighlighting.
Visual Studio does put unformatted text on the clipboard, but it also puts formatted text. (The clipboard supports multiple simultaneous formats, and the OS assumes that they're simply different representations of the same data, although there's no technical enforcement of that point.)
The application you're using to paste then chooses its preferred format. In Word, and maybe Outlook as well, there is a "Paste Special" command that allows you to choose which format you want to use.
My department uses PureText. Sits in the system tray; copy text, click-it - strips all formatting leaving the plain-vanilla text. I'm sure it's much like PlainTextClipboard.
"PureText is basically equivalent to
opening Notepad, doing a PASTE,
followed by a SELECT-ALL, and then a
COPY. The benefit of PureText is
performing all these actions with a
single Hot-Key and having the result
pasted into the current window
automatically."
The goad for this was flaky Lotus Notes; likes to crash when pasting HTML-marked-up-text that I innocently copied from a web-page....
If you press CTRL+Z after pasting, it will reverse to the non-formatting one, because the formatting actually counts as one step after the regular paste.
When I do it choosing the little pop-up menu option attached to the wee clipboard item "Match Destination Formatting" does the trick for me.
From this blog post I got these instructions for getting rid of the black background when copying & pasting out of VS with the 'Dark Theme' activated, but the html in it can be tweaked to alter the rest of the formatting as required (e.g. set all text to black).
If required, install Productivity Power Tools
Open Tools → Extensions and Updates
Select Online (Visual Studio Gallery) and search for Productivity Power Tools 2012/2013
Download and restart Visual Studio when prompted
Productivity Power Tools Settings
Open Tools → Options → Expand Productivity Power Tools
select HTML Copy
Change the BeforeCodeSnippet option to:
<style type="text/css">.identifier {color:black !important;}</style>
<pre style="{font-family}{font-size}{font-weight}{font-style}">
Change EmitSpanClass to: True
Check EmitSpanStyle is: True
You might find http://www.extrabit.com/plaintextclipboard/ to be a useful tool. Some applications have a paste option which strips formatting, but what you really need is a copy operation that strips formatting, which VS does not offer.
In Outlook 2007, I've changed my default paste to do text only.
Go to Editor Options | Advanced
Under the "Cut, copy, paste" heading choose Pasting from other programs: [Keep Text Only]
And if you still want to paste formatted (less often in my case), use paste special...
Search editor.copyWithSyntaxHighlighting in Settings and disable it. Whoever enabled it by default must be flogged.
This Microsoft Office site offers a workaround that involves writing a macro to replace ctrl+v functionality to paste plain text all the time, but that may not be what you want. You can alternatively remap an unused shortcut (ctrl+?) to provide you with this functionality so you don't have to keep enabling / disabling the macro.
For applications that do not have a "paste special" you could use an application like PureText
The Visual Studio Extension Copy for review may be handy for you. Actually, it does not do unformatted copying, but applies it's own simple text-based template.
It supports a "Stack Overflow" format, which just removes the leading whitespace, while keeping the indentation as much as possible, and introduces some sort of header.
Get it from the from the Visual Studio Gallery and try it out.
Disclosure: I am the author of that Extension. Please notfiy me, if I can improve it to your needs.
A trick when applies:
You don't want to install an extension
Your destination application doesn't have options such as "Paste Special"..
You can copy the code and paste it in VS Code search box (shows when you press Ctrl+F). Then copy it again from there.
Then you can paste unformatted text anywhere you want.

Resources