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

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.

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.

Changing the default path of Visual Studio Code's integrated terminal

I'm trying to change the default path of the integrated terminal in Visual Studio Code, but I'm not sure how to. I do know how to change it in the windows command prompt, but not in Visual Studio Code. I looked in user settings, but I can't find anything there to change.
The current default path is C:\Users\User_Name.
I'd like to change it to C:\Project.
How do I do this in Visual Studio Code?
Short answer
Edit the user preference "terminal.integrated.cwd": "" to the path that you want the integrated terminal to open to.
Long answer
The same answer, but the long step-by-step version,
In Visual Studio Code go to:
Menu File → Preferences → Settings
Now that you are in the "User Settings", using the "Search Settings" bar across the top of the window paste or type this:
terminal.integrated.cwd
It will list the following as a result:
// An explicit start path where the terminal will be launched, this is used
as the current working directory (cwd) for the shell process. This may be
particularly useful in workspace settings if the root directory is not a
convenient cwd.
"terminal.integrated.cwd": "",
You will notice that it will not let you type here to change this setting. That is because you can't change the default setting. You instead need to change your personal settings. Here's how...
Click the pencil icon to the left of the this option and then the "Copy to Settings" option that pops-up.
You should have a split screen in which the right side of the screen has the heading Place your settings here to overwrite the Default Settings. This is the correct place for you to make changes. You might already have a few personalized settings listed here.
When you clicked "Copy to Settings" it automatically added this line for you:
"terminal.integrated.cwd": ""
Notice that whichever item is last in this list will not have a trailing comma but any items before it in the list will require one.
FYI: you could have simply typed or copy/pasted this into the personalized settings yourself, but following these steps is the process to learn for changing other preferences as needed.
Now you are able to type to set the path you want to use. Make sure to use \\ in place of \ and you do not need the trailing \. For example including this line would always start your terminal in the baz directory:
{
"terminal.integrated.cwd": "C:\\Users\\foo\\bar\\baz"
}
To apply the change, simply Save and restart Visual Studio Code.
As others have already explained, you can add a setting to change the default folder for your integrated terminal to start in. This setting also accepts Visual Studio Code variables, so to make a relative path from the root folder of your workspace you can use ${workspaceFolder}.
For example, for your terminal to always start in the subfolder mystart, your setting would be:
"terminal.integrated.cwd": "${workspaceFolder}/mystart"
Thanks for the original answer from Peter. Definitely helped !
It has now slightly changed in more recent versions of VS Code.
Navigate to File -> Preferences -> Settings
Type cwd in search
Choose Terminal > Integrated: Cwd settings
Type the default path you want to set in the text block below (simply, no need for double hashes to escape)
No need for saving, It's automatic
Restart VS Code
terminal cwd screen
Try this option in the "Intergrated Terminal" section of Settings.
"terminal.integrated.cwd": "",
You can also set it to a relative path to the open folder with
"terminal.integrated.cwd": "./example"
So if you do menu File → Open Folder... → project, and open the terminal with your keyboard shortcut, it will open to ~/project/example automatically.
It can be a general folder like src you would always use, or a specific one (but then it would be best to save it in file .vscode/settings.json).
The below option will help you do this.
Menu File → Preferences → Settings.
Add or edit the below setting.
terminal.integrated.shell.windows": ""
From the next terminal it will be reflected.
And add file .profile to your default shell, and add the default path to it.
More information can be found
at Integrated Terminal.

Disable Auto-Tab in Visual Studio via a dat file

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.

Sublime MarkdownEditing plugin color scheme and line numbers

I like to utilize Markdown for a lot of the text that I write. To that end I wanted to try out the MarkdownEditing plugin for Sublime Text 3, but am having some user experience issues:
I cannot figure out how to change the color scheme such that it affects the MarkdownEditing syntax editor. Changes to .Packages\User\Preferences.sublime-settings do not effect display settings when in this syntax highlighting mode. However, those changes are reflected in other tabs. How do I change the color scheme when making use of the MarkdownEditing syntax highlighting?
How do I turn on line numbers when making use of this syntax plugin?
TL;DR
If you are using Markdown GFM syntax, open/create "Data/Packages/User/Markdown.sublime-settings" and add:
{
"color_scheme": "Packages/your/custom.tmTheme",
"line_numbers": true
}
See menu: Preferences > Package Settings > MarkdownEditing.
There are 3 different settings there for 3 different syntaxes. First check what "default" settings does and then undo it in "user" settings.
To stop the MarkdownEditing package from overriding your color scheme on Markdown files:
Open Preferences > Settings - User
Find your color_scheme line - e.g. it looks like
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
Copy the entire line
Open Preferences > Package Settings > Markdown Editing > Markdown GFM Settings - Default
Comment out the other color_scheme lines by adding // in front of them
Paste your line instead
Save the file
Markdown files will now use your regular color scheme rather than using their own scheme just for .md files.
If you get an error about "Error trying to parse settings", make sure your line ends with a , if there are lines below it, and does not end with , if it is the last line.
This was one of the most annoying things about this plugin when I installed it a while back, so I promptly got rid of it. However, before doing so, I figured out how to solve your problems. First, since you're using ST3, you'll need to install the quite-useful PackageResourceViewer plugin. Open the Command Palette (CtrlShiftP on Windows), type in prv to bring up the PackageResourceViewer options, and select Extract Package. Scroll down and select MarkdownEditing, hit Enter, and you're all set. You can now open Packages/MarkdownEditing (Packages should be in C:\Users\username\AppData\Roaming\Sublime Text 3, also available by selecting Preferences -> Browse Packages...) in the sidebar and browse through all the different .sublime-settings files for the different syntaxes and for the main plugin, changing things as you want. The syntax-specific files use all the same options found in Preferences -> Settings-Default, so for example you can set "line_numbers": true to turn line numbering back on, and change the value of "color_scheme" to your preferred value.
I had another packaged named Markdownlight which was overriding the color scheme. I had to uninstall it before the color_scheme in the MarkdownEditing user settings took affect.

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

Resources