void (@NotNull AnActionEvent e) { Project project = e.getRequiredData(CommonDataKeys.PROJECT); FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project); VirtualFile selectedFile; final EditorWindow window = e.getData(EditorWindow.DATA_KEY); if (window != null) { window.closeAllExcept(e.getData(CommonDataKeys.VIRTUAL_FILE)); return; } selectedFile = fileEditorManager.getSelectedFiles()[0]; for (final VirtualFile sibling : fileEditorManager.getSiblings(selectedFile)) { if (!Comparing.equal(selectedFile, sibling)) { fileEditorManager.closeFile(sibling); } } }