How to move a File to another Folder in VS Code

avatar
Borislav Hadzhiev

Last updated: Apr 6, 2024
3 min

banner

# How to move a File to another Folder in VS Code

The easiest way to move a file to another folder in VS Code is to use drag and drop.

move file to different folder

Once you drop the file into the new folder, you will be prompted for confirmation.

You can also drag and drop files from outside VS Code to Explorer to copy the file into your project.

If you drag and drop an external file into the main code Window in VS Code, its contents are shown but the file isn't copied into your project.

# Automatically updating imports when files are moved

Notice that the import got automatically updated when I moved the file to a different folder.

move file to different folder

To specify if you want to automatically update imports when a file is moved:

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).
Note: you can also press F1 to open the Command Palette.
  1. Type user settings and select Preferences: Open User Settings.

open user settings

You can also open the settings screen by pressing Ctrl + , on Windows and Linux or Cmd + , on macOS.

  1. Type update imports and set the values for the Update imports on File Move settings.

update imports on file move settings

You can set the setting for JavaScript and TypeScript.

There are 3 possible values:

  • prompt - when a file is moved, you get prompted whether you want to update imports.
  • always - always update imports when a file is moved.
  • never - never update imports when a file is moved and don't prompt.

# Move a file using Ctrl + X and Ctrl + V

You can also use the Ctrl + X and Ctrl + V keyboard shortcuts.

If you are on macOS, use Cmd + X and Cmd + V instead.

  1. Select the file in Explorer.
  2. Press Ctrl + X.
  3. Select the folder you'd like to move the file to.
  4. Press Ctrl + V.

move file using ctrl x ctrl v

You can also use the arrow keys to navigate to the folder to which you want to move the file.

using arrow keys to navigate in explorer

# Move multiple files to another folder in VS Code

If you need to move multiple files to another folder:

  1. Press and hold Ctrl (or Cmd on macOS).
  2. Select the files in Explorer.
  3. Drag and drop the files into the folder.

move multiple files to different folder

You can also use the Shift key to select multiple files and then use the Ctrl (or Cmd) key to exclude ones you don't want to move.

using shift key to move multiple files

# Using an extension to move Files in Visual Studio Code

You can also use an extension to move files in VS Code:

  1. Click on Extensions in the left sidebar.
  • You can also open the Extensions menu by pressing:
    • Ctrl + Shift + X on Windows or Linux.
    • Command + Shift + X on macOS.
  1. Type File Utils.

install file utils extension

  1. Click on the Install button.

Make sure to install the File Utils extension by Steffen Leistner as shown in the screenshot.

Once you install the extension:

  1. Right-click on the file in Explorer and select Move.

right click select move

  1. Once you select Move, you get prompted to specify the location to move the file to.

specify location to move file to

Note that you have to specify the entire path to the new location.

For example, from:

shell
/home/user/Desktop/bobbyhadz-vscode/index.js

To:

shell
/home/user/Desktop/bobbyhadz-vscode/my-folder/index.js

You can also use the command palette to trigger the command:

  1. Open the file you'd like to move.

  2. Press:

  • Ctrl + Shift + P on Windows and Linux.
  • Command + Shift + P on macOS.
Note: you can also press F1 to open the Command Palette.
  1. Type File Utils Move and select the option.

move file using command palette

Here is a short clip that demonstrates the process.

moving a file using file utils

I've also written a detailed guide on how to hide specific files or folders from the left sidebar.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.