# Safe delete

> **TL;DR**
> `Refactor | Safe Delete`
>
>
>
> `Alt+Delete` (Windows), `⌘ ⌦` (macOS), `⌘ ⌦` (IntelliJ IDEA Classic (macOS)), `⌘ ⌦` (macOS System Shortcuts), `Alt+Delete` (XWin), `Alt+Delete` (GNOME), `Alt+Delete` (KDE), `Alt+Delete` (Emacs), `Alt+Delete` (Sublime Text), `⌘ ⌦` (Sublime Text (macOS)), `⌘ ⌦` (Xcode), `Ctrl+R, D` (Visual Studio), `⌘ R, D` (Visual Studio (macOS)), `Alt+Delete` (ReSharper), `⌥ ⌦` (ReSharper (macOS)), `Alt+Delete` (QtCreator), `⌘ ⌦` (QtCreator (macOS)), `Alt+Delete` (NetBeans), `Alt+Delete` (Eclipse), `Alt+Delete` (Eclipse (macOS))

With the Safe Delete refactoring, you can safely remove files and symbols from the source code.

Procedure:

1. Select the item to be deleted.

2. Press `Alt+Delete` (Windows), `⌘ ⌦` (macOS), `⌘ ⌦` (IntelliJ IDEA Classic (macOS)), `⌘ ⌦` (macOS System Shortcuts), `Alt+Delete` (XWin), `Alt+Delete` (GNOME), `Alt+Delete` (KDE), `Alt+Delete` (Emacs), `Alt+Delete` (Sublime Text), `⌘ ⌦` (Sublime Text (macOS)), `⌘ ⌦` (Xcode), `Ctrl+R, D` (Visual Studio), `⌘ R, D` (Visual Studio (macOS)), `Alt+Delete` (ReSharper), `⌥ ⌦` (ReSharper (macOS)), `Alt+Delete` (QtCreator), `⌘ ⌦` (QtCreator (macOS)), `Alt+Delete` (NetBeans), `Alt+Delete` (Eclipse), `Alt+Delete` (Eclipse (macOS)) or call `Refactor | Safe Delete` from the main menu.

3. In the [Safe Delete dialog](), select the necessary options and click OK:

![Safe Delete dialog](https://resources.jetbrains.com/help/img/idea/2026.2/cl_safedelete_dialog.png)

4. If the refactoring is potentially unsafe, the Usages Detected dialog opens.

![Usages Detected dialog](https://resources.jetbrains.com/help/img/idea/2026.2/cl_safedeleteUsages.png)

* View Usages. Click this button to see where in your code the item you are about to delete is used: ![Find tool window](https://resources.jetbrains.com/help/img/idea/2026.2/cl_safedeleteView.png) Analyze your code and make the necessary corrections. Click Do Refactor when ready. > **Tip:** > If you want to rerun the refactoring from the start, click Rerun Safe Delete. CLion will check if the refactoring is safe once more.

* Delete Anyway. Click this button to delete the item without checking the usages.

## Safe Delete for files in CMake projects

When you delete files referenced in CMake commands, CLion performs Safe Delete.

![Safe delete for files](https://resources.jetbrains.com/help/img/idea/2026.2/cl_safedelete_cmake.png)

Safe Delete for files and their references in `CMakeLists.txt` is supported for the following commands:

* `add_executable()`;

* `add_library()`;

* `set()`;

* `add_custom_target_command()`;

* `fltk_wrap_ui()`;

* `qt_wrap_cpp()`;

* `qt_wrap_ui()`:

* `set_property()`;

* `set_source_files_properties()`;

* `try_compile()`.

> **Note:**
> If the file you are going to delete is the only argument of a CMake command (for example, `add_executable(foobar foo.cpp)`), this command might become incorrect after deletion.

## See also

### Reference

[Find tool window](find-tool-window.html)

### External Links

[JetBrains CLion Blog](http://blog.jetbrains.com/clion/2014/12/refactorings-in-clion-be-safe-and-quick/)

