Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I still have to format the code #237022

Open
PawelPatyk opened this issue Dec 27, 2024 · 3 comments
Open

I still have to format the code #237022

PawelPatyk opened this issue Dec 27, 2024 · 3 comments
Assignees

Comments

@PawelPatyk
Copy link

Type: Bug

Hello,
I have been having a problem with pasting and typing code for a long time.
The issue is that when I copy a piece of code and paste, the pasted code is aligned to the left.
The same goes for going to a new line and typing a phrase - then the phrase moves to the left!
It's hard to write code like this when I constantly have to format it.
Video showing what this is all about:
https://1drv.ms/v/c/150f8e3ec553a9eb/Ec0ooke9LR1NlGrekjUPea8B1J8z18M1jiMD5lWDMCkngA?e=hxPUCw

VS Code version: Code 1.96.2 (fabdb6a, 2024-12-19T10:22:47.216Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7 CPU 950 @ 3.07GHz (8 x 3074)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 11.99GB (1.14GB free)
Process Argv E:\wamp64\www\wordpress\wp-content\themes\mytheme\page.php --crash-reporter-id a40e7615-7e61-4612-a4be-2156976f19c5
Screen Reader no
VM 0%
Extensions (7)
Extension Author (truncated) Version
smarty-template-support asw 2.1.1
cssrem cip 4.1.0
dscodegpt Dan 3.5.175
figma-vscode-extension fig 0.4.0
live-sass gle 6.1.2
easy-less mrc 2.0.2
vscode-language-pack-pl MS- 1.96.2024121109
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
pythonvspyt551:31179978
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupyter:31046869
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1:31157159
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

@ParamSingh24
Copy link

Title: "How to Fix Misaligned Code in VS Code by Enabling Format on Paste"

Hi ,

If you're struggling with misaligned code when pasting or typing in VS Code, I recommend enabling the Format on Paste feature. This has worked well for me and might help you too!

How to Enable Format on Paste
Open your VS Code settings. You can do this quickly by pressing Ctrl + , (or Cmd + , on Mac).
In the search bar, type formatOnPaste.
Look for the Editor: Format On Paste option and check the box to enable it.
Why This Works
When you enable Format on Paste, VS Code will automatically format the pasted code based on your project's formatting rules. This means:

Pasted code will align properly with the rest of your file.
You won’t need to manually fix the formatting after every paste.
Additional Tips
Make sure your formatter is configured properly. If you're using Prettier or ESLint, double-check that your configuration files (like .prettierrc or .eslintrc) match your project's style.
Customize indentation settings. In VS Code settings, ensure options like editor.tabSize and editor.insertSpaces are aligned with your preferences or the project’s standards.
If you’re still seeing issues, try disabling all extensions temporarily to rule out conflicts with formatters.
This feature has been a game-changer for me, and I hope it helps make your coding experience smoother too!

Let me know if you have any questions or if there’s anything I can clarify further.

@PawelPatyk
Copy link
Author

PawelPatyk commented Dec 28, 2024

Enable the 'Format on Paste' option did nothing.
Disabling all extensions did not help.

@ParamSingh24
Copy link

bro you can
Check editor.formatOnType. If it's enabled, VS Code might be formatting your code automatically when you type or paste
&
A .editorconfig file or a specific linter/formatter (like Prettier or ESLint) in your project might be enforcing alignment rules.
Open .editorconfig or check your formatter settings to ensure they're not misconfigured.
&
if the issue persists, consider resetting VS Code to its default settings:
Delete or rename the settings.json file located in C:\Users<YourUser>\AppData\Roaming\Code\User.
&
update it if it is not ,
last option reinstall your vs code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants