You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: release-notes/v1_96.md
+56-2Lines changed: 56 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -201,7 +201,7 @@ You can also access this setting by right-clicking in the title area, and select
201
201
202
202
When you drag and drop or copy & paste a file into a text editor, VS Code provides multiple ways to insert it into that file. By default, VS Code tries to insert the file's workspace relative path. Now you can use the drop/paste control to switch how the resource is inserted. Extensions can also provide customized edits, such as in Markdown, which [provides edits that insert Markdown links](https://code.visualstudio.com/updates/v1_67#_markdown-drop-into-editor-to-create-link).
203
203
204
-
With the new `setting(editor.pasteAs.preferences)` and `setting(editor.dropIntoEditor.preferences)` settings, you can now specify a preference for which edit type to use by default. For example, if you'd like copy/paste to always insert the absolute path of pasted files, just set:
204
+
With the new `setting(editor.pasteAs.preferences)` and `setting(editor.dropIntoEditor.preferences)` settings, you can now specify a preference for which edit type will be used by default. For example, if you'd like copy/paste to always insert the absolute path of pasted files, just set:
205
205
206
206
```json
207
207
"editor.pasteAs.preferences": [
@@ -370,7 +370,61 @@ Our JavaScript and TypeScript support now uses TypeScript 5.7. This major update
370
370
You can read all about the TypeScript 5.7 release on the [TypeScript blog](https://devblogs.microsoft.com/typescript/announcing-typescript-5-7/). We've also included a few tooling highlights in the following sections.
371
371
372
372
### Paste with imports for JavaScript and TypeScript
373
-
@mjbvz to complete this
373
+
Tired of having to add imports after moving code between files? Try the 'paste with imports' feature for TypeScript 5.7+. Now whenever you copy and paste code between JavaScript or TypeScript, VS Code can add imports for the pasted code:
374
+
375
+
<videosrc="images/1_96/jsts-update-imports-paste.mp4"title="Imports being automatically updated when "autoplayloopcontrolsmuted></video>
376
+
377
+
Notice how it not only added imports, it even added a new export for a local variable that was used in the pasted code!
378
+
379
+
While we think this feature will be a huge time saver, we also are sensitive to disrupting your existing workflows. By default, copy and paste will always insert just the pasted text. If a `paste with imports` edit is available, you'll then see the paste widget which lets you select the `paste with imports` edit:
380
+
381
+

382
+
383
+
If you prefer always pasting with imports, you can [use the new `editor.pasteAs.preferences` setting](#configure-paste-and-drop-behavior):
384
+
385
+
```json
386
+
"editor.pasteAs.preferences": [
387
+
"text.updateImports"
388
+
]
389
+
```
390
+
391
+
This will always try pasting with imports if an edit is available.
392
+
393
+
You can also setup a keybinding to paste with imports:
394
+
395
+
```json
396
+
{
397
+
"key": "ctrl+shift+v",
398
+
"command": "editor.action.pasteAs",
399
+
"args": {
400
+
"preferences": [
401
+
"text.updateImports"
402
+
]
403
+
}
404
+
}
405
+
```
406
+
407
+
If you prefer, you can even do the reverse and make paste with imports the default and add a keybinding to paste as plain text:
408
+
409
+
```json
410
+
"editor.pasteAs.preferences": [
411
+
"text.updateImports"
412
+
]
413
+
```
414
+
415
+
```json
416
+
{
417
+
"key": "ctrl+shift+v",
418
+
"command": "editor.action.pasteAs",
419
+
"args": {
420
+
"preferences": [
421
+
"text.plain"
422
+
]
423
+
}
424
+
}
425
+
```
426
+
427
+
Finally if you want to fully disable `paste with imports`, you can use `setting(typescript.updateImportsOnPaste.enabled)` and `setting(javascript.updateImportsOnPaste.enabled)`.
0 commit comments