Skip to content

Commit f47fd46

Browse files
committed
Document TS paste with imports
1 parent 422c44d commit f47fd46

File tree

4 files changed

+65
-2
lines changed

4 files changed

+65
-2
lines changed
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:ce1f11fc027929ae66c9686339e4d15d78f43630b014dbf1f9a8bcc93d25c0c7
3+
size 355837

release-notes/v1_96.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ You can also access this setting by right-clicking in the title area, and select
201201

202202
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).
203203

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:
205205

206206
```json
207207
"editor.pasteAs.preferences": [
@@ -370,7 +370,61 @@ Our JavaScript and TypeScript support now uses TypeScript 5.7. This major update
370370
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.
371371

372372
### 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+
<video src="images/1_96/jsts-update-imports-paste.mp4" title="Imports being automatically updated when " autoplay loop controls muted></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+
![alt text](images/1_96/jsts-paste-widget.png)
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)`.
374428

375429
## Remote Development
376430

0 commit comments

Comments
 (0)