Visual Studio Code terminal cursor mid word - visual-studio-code

Not really sure how to describe the issue, but the cursor is in the middle of the output text. I'm uploading a gif for clarification. In the MacOS Terminal app it does not happen. Any idea? I've checked the Terminal Cursor settings but I could only found things like the width or the style.
I think I don't have anything weird in the .zshrc
export LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN=1
export AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1
export PATH="/Users/jorgeanzola/config-files/helpers:$PATH"
DEFAULT_USER="jorgeanzola"
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="af-magic"
ENABLE_CORRECTION="true"
plugins=(git zsh-autosuggestions zsh-syntax-highlighting docker docker-compose laravel)
source $ZSH/oh-my-zsh.sh
export EDITOR='code'

Related

VS Code Not Running Anything - No such file or directory

My VS Code
My VSCode for Mac won't run even simple Python commands. For more context my Python Terminal execute in file dir setting is turned on. I don't know what the problem is, the play button or right clicking and selecting run code also doesn't do anything.
I've already ensured I have the proper VSCode installed for Mac. Please help :(
try to edit your settings.json file like this :
"terminal.explorerKind": "external",
"terminal.integrated.defaultProfile.windows": "Command Prompt"
learn more about using python in VS Code

Need help assigning global settings for Rstudio's pandoc in VSCode to knit pdf_document in a .rmd output format

So I am migrating from RStudio to Visual Studio Code for my future R projects. I have successfully gotten my github aspect all setup and I am trying to write my code in (.rmd) format so that I can knit it to pdf, html and flex_dashboard outputs. When I have tried to knit the it, I get the following error:
rmarkdown::render("c:\Users\{user}\{folder}\{sub-folder}\{sub-folder}\Co$
Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).>
I found the following solution that once run in the terminal, allows it to knit into a pdf_document successfully.
Code: Sys.setenv(RSTUDIO_PANDOC="--- insert directory here ---")
Reference: pandoc version 1.12.3 or higher is required and was not found (R shiny)
This is great, but everytime I restart VSCode, this setting appears to be reset and I have to run it again. Is there away to set this globally so that I don't have to run it every time I use it? Or is there a better way to do this?
I had a similar problem before in VScode to render R markdown. Now, I found the solutions to it.
Following the steps below to properly set up the pandoc:
Step 1:
Go to your R Studio and go the console, type the following:
Sys.getenv("RSTUDIO_PANDOC")
If you are using MacOS, you will get the path for "pandoc": "/Applications/RStudio.app/Contents/MacOS/pandoc"
If you are using Windows, you probably will get the path like:
"/c/Program Files/RStudio/bin/pandoc/" as mentioned in pandoc version 1.12.3 or higher is required and was not found (R shiny)
Step 2:
Paste the path of "pandoc" and put it into your bash or zsh (depends on what command shell that you are using).
On MacOS, I'm using zsh. Therefore, I add the following path into ~/.zshrc:
export RSTUDIO_PANDOC="/Applications/RStudio.app/Contents/MacOS/pandoc"
As for how to edit ~/.zshrc, one way to do this is presented as follows:
step 2.1
nano ~/.zshrc
It will open your .zshrc file and navigate to the bottom of this file, paste the
export RSTUDIO_PANDOC="/Applications/RStudio.app/Contents/MacOS/pandoc". Then, control + X to exit. It will ask about "Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?", then type Y and type return bottom.
step 2.2
source ~/.zshrc
Now, it should work fine in VScode. By checking if it works, you could open your console by typing R to invoke the R environment and type Sys.getenv("RSTUDIO_PANDOC"). If it returns the path of the "pandoc", it would work fine in VScode as well.
Adding
"terminal.integrated.env.osx": {
"RSTUDIO_PANDOC":"/Applications/RStudio.app/Contents/MacOS/pandoc"
}
into settings.json worked for me.
Adding to .zshrc didn't work at all since the System environment wasn't being passed on to the integrated terminal.

Visual Studio Code edit file

When I try to edit a file in visual studio code, I type the command 'code filename.ps1' and the code used to automatically open as a second tab in the editor.
Now, when I do the same thing, it opens in a new window. I have not changed anything in my settings and I can't find an associated Preference that controls this.
Anyone know exactly the default setting that I need to look at?
According to CLI Options this should work:
code -r filename.ps1
>
-r or --reuse-window
Forces opening a file or folder in the last active window.

Editing WSL config files\code etc with Visual Studio Code, in Windows

I am really enjoying WSL and using it for a lot of stuff these days, including my Ansible workstation, also writing a lot more code in it...
Question: I can see where the WSL file system is:
https://askubuntu.com/questions/759880/where-is-the-ubuntu-file-system-root-directory-in-windows-nt-subsystem-and-vice
All of the docs tell you very clearly to stay away from the Linux file system and not to access it from the Windows instance it is running under. Fine. But! I hate to ask redundant question, but I would dearly, dearly love to be able to use full blown graphical VS Code in Windows in my text editor for WSL. Am i missing a trick somewhere for a way to do this without breaking anything?
Apologies for the non question. Hopefully it is allowed.
In vscode...
You can press the green icon bottom-left
This will open the command palette
Choose "New WSL Window"
Open a folder, you will be able to navigate from ~ to choose location in command palette
Once folder is choosen, you're set to go, vscode will display file tree from opened folder and you can do your thing :)

zsh doesn't work in the vscode built-in terminal

echo $SHELL
logged: /bin/zsh
why the built-in shell is still bash
what should I config vscode the to make the zsh works in the built-in terminal?
For those who are using MAC
Launch Visual Studio Code and go to Settings.
In Settings, click on the features dropdown and then on Terminal
Click on edit in settings.json (the icon at the top right) and add this line of code to the user settings json file:
"terminal.integrated.shell.osx": "/bin/zsh"
then you must close that terminal with the trash icon.
that's it, now if you open another terminal you should see the ZSH terminal.
#Ale's answer is no longer valid! It should be used the following instead:
"terminal.integrated.defaultProfile.osx": "zsh"
You can set the terminal.integrated.shell.linux property as described here. If you need to pass arguments to zsh, use the terminal.integrated.shellArgs.linux property.
#ccoutinho updated Ale DC's answer to the proper path:
"terminal.integrated.defaultProfile.osx": "zsh"
But I also needed Ale DC's extra tip to trash the currently displayed embedded terminal (clicking the trash icon at the top right of the terminal tab). Otherwise I had one instance showing zsh and another refused to show zsh and it was driving me crazy.
Hope that helps.