From 77ecb2eaa789911953fd551886e966d66d1e5451 Mon Sep 17 00:00:00 2001 From: Marco Candrian Date: Wed, 5 Dec 2007 14:50:59 +0000 Subject: [PATCH] :imap, :imapclear, :inoremap, :iunmap added --- content/commands.js | 58 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/content/commands.js b/content/commands.js index c3918025..443270fa 100644 --- a/content/commands.js +++ b/content/commands.js @@ -1348,6 +1348,15 @@ vimperator.Commands = function () //{{{ "Mappings are NOT saved during sessions, make sure you put them in your vimperatorrc file!" } )); + commandManager.add(new vimperator.Command(["im[ap]"], + function (args) { map(args, [vimperator.modes.INSERT], false); }, + { + usage: ["imap {lhs} {rhs}", "imap {lhs}", "imap"], + shortHelp: "Map the key sequence {lhs} to {rhs} (in insert mode)", + help: "The {rhs} is remapped, allowing for nested and recursive mappings.
" + + "Mappings are NOT saved during sessions, make sure you put them in your vimperatorrc file!" + } + )); commandManager.add(new vimperator.Command(["mapc[lear]"], function (args) { @@ -1382,6 +1391,23 @@ vimperator.Commands = function () //{{{ ":cmap or :cnoremap are cleared." } )); + commandManager.add(new vimperator.Command(["imapc[lear]"], + function (args) + { + if (args) + { + vimperator.echoerr("E474: Invalid argument"); + return; + } + + vimperator.mappings.removeAll(vimperator.modes.INSERT); + }, + { + shortHelp: "Remove all mappings (in insert mode)", + help: "All user-defined mappings which were set by " + + ":imap or :inoremap are cleared." + } + )); commandManager.add(new vimperator.Command(["ma[rk]"], function (args) { @@ -1448,7 +1474,7 @@ vimperator.Commands = function () //{{{ line += "\" Mappings\n"; // TODO: write user maps for all modes when we have mode dependant map support - var mode = [[vimperator.modes.NORMAL, ""], [vimperator.modes.COMMAND_LINE, "c"]]; + var mode = [[vimperator.modes.NORMAL, ""], [vimperator.modes.COMMAND_LINE, "c"], [vimperator.modes.INSERT, "i"]]; for (var y = 0; y < mode.length; y++) { for (var map in vimperator.mappings.getUserIterator(mode[y][0])) @@ -1540,6 +1566,14 @@ vimperator.Commands = function () //{{{ help: "No remapping of the {rhs} is performed." } )); + commandManager.add(new vimperator.Command(["ino[remap]"], + function (args) { map(args, [vimperator.modes.INSERT], true); }, + { + usage: ["ino[remap] {lhs} {rhs}", "ino[remap] {lhs}", "ino[remap]"], + shortHelp: "Map the key sequence {lhs} to {rhs} (in insert mode)", + help: "No remapping of the {rhs} is performed." + } + )); commandManager.add(new vimperator.Command(["o[pen]", "e[dit]"], function (args, special) { @@ -2381,6 +2415,28 @@ vimperator.Commands = function () //{{{ help: "" } )); + commandManager.add(new vimperator.Command(["iunm[ap]"], + function (args) + { + if (!args) + { + vimperator.echoerr("E474: Invalid argument"); + return; + } + + var lhs = args; + + if (vimperator.mappings.hasMap(vimperator.modes.INSERT, lhs)) + vimperator.mappings.remove(vimperator.modes.INSERT, lhs); + else + vimperator.echoerr("E31: No such mapping"); + }, + { + usage: ["iunm[ap] {lhs}"], + shortHelp: "Remove the mapping of {lhs} (in insert mode)", + help: "" + } + )); commandManager.add(new vimperator.Command(["ve[rsion]"], function (args, special) {