/*
 * IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
 * Copyright (C) 2003-2014 The IdeaVim authors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package com.maddyhome.idea.vim.ex.handler;

import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.util.text.StringUtil;
import com.maddyhome.idea.vim.ex.CommandHandler;
import com.maddyhome.idea.vim.ex.ExCommand;
import com.maddyhome.idea.vim.ex.ExException;
import com.maddyhome.idea.vim.ex.ExOutputModel;
import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * @author smartbomb
 */
public class ActionListHandler extends CommandHandler {
  public ActionListHandler() {
    super("actionl", "ist", RANGE_FORBIDDEN | DONT_REOPEN | ARGUMENT_OPTIONAL);
  }

  public boolean execute(@NotNull Editor editor, @NotNull final DataContext context,
                         @NotNull ExCommand cmd) throws ExException {
    final String arg = cmd.getArgument().trim().toLowerCase();
    final List<String> args = StringUtil.split(arg, "*");
    final ActionManager actionManager = ActionManager.getInstance();
    final String actionNames[] = actionManager.getActionIds("");
    final StringBuilder builder = new StringBuilder();

    for (String actionName : actionNames) {
      if (match(actionName, args)) {
        builder.append(actionName);
        final AnAction action = actionManager.getAction(actionName);
        final Shortcut[] shortcuts = action.getShortcutSet().getShortcuts();
        for (Shortcut shortcut : shortcuts) {
          builder.append(" ");
          builder.append(shortcut.toString());
        }
        builder.append("\n");
      }
    }

    final String result = builder.toString();
    ExOutputModel.getInstance(editor).output(result.length() != 0 ? result : "No results\n");
    return true;
  }

  private boolean match(@NotNull String actionName, @NotNull List<String> args) {
    for (String argChunk : args) {
      if (!actionName.toLowerCase().contains(argChunk)) {
        return false;
      }
    }
    return true;
  }
}

@@ -850,177 +850,9 @@
 tem.
-ActionManager;%0Aimport com.intellij.openapi.actionSystem.AnAction;%0Aimport com.intellij.openapi.actionSystem.DataContext;%0Aimport com.intellij.openapi.actionSystem.Shortcut
+*
 ;%0Aim
@@ -1140,43 +1140,149 @@
 ort 
-org.jetbrains.annotations.NotNull;%0A
+com.maddyhome.idea.vim.helper.StringHelper;%0Aimport org.jetbrains.annotations.NotNull;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collections;
 %0Aimp
@@ -1858,22 +1858,28 @@
   final 
+List%3C
 String
+%3E
  actionN
@@ -1886,13 +1886,25 @@
 ames
-%5B%5D
  = 
+Arrays.asList(
 acti
@@ -1929,18 +1929,86 @@
 nIds(%22%22)
+)
 ;%0A
+    Collections.sort(actionNames, String.CASE_INSENSITIVE_ORDER);%0A%0A
     fina
@@ -2053,16 +2053,57 @@
 ilder();
+%0A    builder.append(%22--- Actions ---%5Cn%22);
 %0A%0A    fo
@@ -2200,26 +2200,61 @@
 .append(
-actionName
+StringHelper.leftJustify(actionName, 50, ' ')
 );%0A     
@@ -2485,41 +2485,224 @@
     
-builder.append(shortcut.toString(
+if (shortcut instanceof KeyboardShortcut) %7B%0A            final KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;%0A            builder.append(StringHelper.toKeyNotation(keyboardShortcut.getFirstKeyStroke()
 ));%0A
@@ -2705,24 +2705,26 @@
 ));%0A        
+ 
+ 
 %7D%0A        bu
@@ -2725,27 +2725,63 @@
     
-builder.append(%22%5Cn%22
+  else %7B%0A            builder.append(shortcut.toString()
 );%0A 
@@ -2789,62 +2789,68 @@
     
-%7D%0A
+    %7D%0A  
     
+  
 %7D
-%0A
 %0A    
-final String result = builder.toString();
+    builder.append(%22%5Cn%22);%0A      %7D%0A    %7D%0A
 %0A   
@@ -2895,54 +2895,26 @@
 put(
-result.length() != 0 ? result : %22No results%5Cn%22
+builder.toString()
 );%0A 

Prettier output of :actionlist