How do I turn on word wrap for Output window in VS code? - python-3.x

I'm running my code using the extension "Code Runner" and would like the output to be displayed word-wrapped. Currently when I run it, it displays the output all in a single line even if it's a long line.
I tried the setting "editor.wordWrap": "on".
This is how the output and editor look like:

Try adding this to your settings:
"[Log]": {
"editor.wordWrap": "on"
}

You can instead use the built-in debugger configuration for Python and set in launch configuration to use the "internalConsole"
{
"name": "run-test-py",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/myfile.py",
"console": "internalConsole"
},
so that the output appears in the Debug Console panel. The word wrapping for that panel is controlled by the Debug > Console: Word Wrap setting:
Set it to true:
"debug.console.wordWrap": false,

For the Debug Console you can use "debug.console.wordWrap": false,//default:true which was added in June 2019 with issue 72210

Related

Autoformatting failed, buffer not changed : Sublime text

While setting up Python Development Environment in Sublime text 3, I wanted Auto formatting on and hence I made the following settings in Preferences > Package settings > Anaconda > Settings User
{
"auto_formatting": true,
"autoformat_ignore":
[
],
"pep8_ignore":
[
"E501"
],
"anaconda_linter_underlines": false,
"anaconda_linter_mark_style": "none",
"display_signatures": false,
"disable_anaconda_completion": true,
"python_interpreter": "/usr/local/bin/python3"
}
The auto_formatting value is set to true in user settings and it is set to false in default settings .
The auto formatting does not work out and gives me Autoformatting failed, buffer not changed error . Also tried changing auto_formatting_timeout = 5 //seconds , but that didn't work out . It would be of great help if someone could help me out .
I had the exact same issue. The problem is the last line is pointing to the wrong path for your python interpreter
Preferences > Package Settings > Anaconda > Settings - User
Delete the last line
"python_interpreter": "/usr/local/bin/python3"
Replace it with
"python_interpreter": "C:\\Users\\YOUR_NAME\\AppData\\Local\\Programs\\Python\\Python38-32\\python.EXE"
IMPORTANT: Your python interpreter path might be different to mine so find out where it is. Remember you need to use TWO backslashes in the path not ONE
Sublime is looking for python in environmental variable when you build it, and it is not able to find it there. You can test it in cmd by typing python and if it opens Microsoft store then here is the fix you can do, it worked for me. Open setting -> search for manage app execution aliases -> turn off "python.exe" and "python3.exe". Now check if you can get python in cmd by typing python, if you do then sublime problem should be fixed. If you want to know why this works follow this stack overflow

Indenting multilines/block with vscode and vim plugin

This is already on the site, but it doesn't work for me. I'm not 100% sure the answer is responsive to my situation (the question asks about vim "mode"). If it is, the context for the accepted answer isn't obvious for me.
I assume were supposed to splice the json fragment
{
"key": "shift+tab",
"command": "outdent",
"when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus"
}
into our settings but it's not clear how or where. The app has a settings.json, a keybindings.json and the plugin has package.json.
I got this to work in vim itself a year or so ago IIRC, but it took a plugin and a couple of settings.
Edit to add: ctrl+[ and ctrl+] aren't functional for me. Presumably they would be w/o the vim plugin, but the plugin overrides the ctrl commands.
Just as in normal vim, typing >> and << in normal mode or > and < in visual mode will indent and un-indent lines, respectively.
Source: https://vim.fandom.com/wiki/Shifting_blocks_visually
Also: https://stackoverflow.com/a/235841/7007605
If you are using the main Vim (VSCodeVim), the standard m>, m<, :m,n>, :m,n< are not supported (see https://github.com/VSCodeVim/Vim/issues/3733).
However, this feature is supported by the Neo Vim VS Extension (asvetliakov.vscode-neovim). Note that if you go this route, you do need to install neovim (>v0.5.0) separately, which you can obtain at https://github.com/neovim/neovim/releases/nightly. Then set the path to the neovim executable/binary in the Neo Vim VS extension settings.
I remaped < and > in normal mode to ident lines while using the VSCode commands:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<"],
"commands" : ["tab"]
},
{
"before": [">"],
"commands" : ["outdent"]
}
]

Input functionality is not working with python in Vscode

Description:
I'm using Vscode Studio for python coding, I've installed every extension related to python and I wanna use Jupyter. I'm experiencing no problem with importing packages or running code but when I try to grab the input from the user it throws me an error stating 'StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.' which I don't find using the console.
[Image Error]
https://i.stack.imgur.com/BDUC5.jpg
Error
StdinNotImplementedError Traceback (most recent call last)
in
9 while 1:
10 #ask for new item
---> 11 new_item=input("> ")
12 #add new items to our list
13 shopping_list.append(new_item)
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ipykernel\kernelbase.py in raw_input(self, prompt)
846 if not self._allow_stdin:
847 raise StdinNotImplementedError(
--> 848 "raw_input was called, but this frontend does not support input requests."
849 )
850 return self._input_request(str(prompt),
StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.
Steps Taken:
Use the raw_input function instead of input.
Install and uninstall python and jupyter extension.
Checked the version of jupyter notebook --version (5.7.4) and python -m ipykernel --version (7.2.0).
Restarted kernel but encounter the same error.
Observation:
The issue is not replicable when the code is executed with python integrated terminal
Please let me know if there is setting which I'm missing or is this a bug.
Ctrl + Shift + D
Environment -> Python
This creates launch.json file within a .vscode directory in the current directory
Paste the following json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config.python.pythonPath}",
"program": "${file}",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
],
"console": "integratedTerminal"
}
]}
Save the file and open python script in the editor
Start without debugging

Sublime Text 3 on Ubuntu: custom keybinds in packages

Problem
My problem is that the custom keybindings that I assign in Sublime Text 3 on Ubuntu are not registered. In my case, I am trying to set them for commands in the 'MarkdownPreview' package.
Setup
I have the following setup:
Ubuntu 16.04
Sublime Text 3 (build 3126)
MarkdownPreview package
Details
My MarkdownPreview.sublime-settings looks as follows (User settings):
[
{"keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"}},
{"enable_mathjax": true}
]
I have already opened the console and set sublime.log_input(True) and sublime.log_commands(True).
The output in the console when pressing alt+m does show the event being registered, but no command is trigged. See this console excerpt:
key evt: backspace
command: left_delete
key evt: alt+m
key evt: control+c
command: copy
I can run the command from the command palette and the "enable_mathjax": true setting works fine
The reason this doesn't work for you is that you've put the key binding in the preferences for the package instead of in the key binding file, where Sublime can't see it.
The mathjax setting you have should be in your MarkdownPrevious.sublime-settings file, as that's a setting for the package. So that file should look like this:
{
/*
Enable or not mathjax support.
*/
"enable_mathjax": true
}
With that done, you want to select Preferences > Key Bindings (or if you're using an older version of sublime, Preferences > Key Bindings - User) and put your key binding in that file:
[
{
"keys": ["alt+m"], "command": "markdown_preview",
"args": {
"target": "browser",
"parser":"markdown"
}
},
]
This shows the complete contents of the key bindings file with only this single key binding. If you have any other custom key bindings, add this to your file without the [ and ] surrounding it (as they will already be in the file).

Visual Studio Code - launch parameter for node app being surrounded by double quotes

I'm having some problems putting a parameter for launching (debugging) a node app from Visual Studio Code. I'm using this config at launch.json:
// Command line arguments passed to the program.
"args": [
"-cache-dig cache"
]
and when launching VS Code surrounds the parameter with double quotes:
node foo.js "-cache-dig cache"
...which is not accepted by this app. Any suggestions?
Change the args key in your launch configuration to put each command line argument in a separate element.
For example:
"args": [
"-cache-dig",
"cache"
]
The reason being that while -cache-dig cache is a single option at the application level, it is actually composed of two separate command line arguments (a name -cache-dig and a value cache).

Resources