Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for i_ctrl-a. That is, while in InsertMode, Ctrl+A will

paste last insert register (".).  This only works if you unbind Ctrl+A
from Eclipse first.

Change-Id: Ibbfc0a9fdf404bfd199c1ceb26ec471dc6120630
  • Loading branch information...
commit e26d036ecb2e2161f75b10b273a25bb82a7245f8 1 parent 890bdb5
keforbes keforbes authored
4 net.sourceforge.vrapper.core/src/net/sourceforge/vrapper/vim/modes/InsertMode.java
View
@@ -40,6 +40,7 @@
public static final KeyStroke ESC = key(SpecialKey.ESC);
public static final KeyStroke CTRL_C = ctrlKey('c');
public static final KeyStroke CTRL_R = ctrlKey('r');
+ public static final KeyStroke CTRL_A = ctrlKey('a');
private Position startEditPosition;
@@ -181,6 +182,9 @@ public boolean handleKey(KeyStroke stroke) {
//move to "paste register" mode, but don't actually perform the
//"leave insert mode" operations
editorAdaptor.changeModeSafely(PasteRegisterMode.NAME, DONT_LEAVE_MODE);
+ } else if (stroke.equals(CTRL_A)) {
+ // i_ctrl-a == i_ctrl-r ".
+ PasteRegisterMode.pasteLastInsert(editorAdaptor);
} else if (!allowed(stroke)) {
startEditPosition = editorAdaptor.getCursorService().getPosition();
count = 1;
8 net.sourceforge.vrapper.core/src/net/sourceforge/vrapper/vim/modes/PasteRegisterMode.java
View
@@ -9,6 +9,7 @@
import net.sourceforge.vrapper.vim.commands.Command;
import net.sourceforge.vrapper.vim.modes.commandline.AbstractCommandParser;
import net.sourceforge.vrapper.vim.register.Register;
+import net.sourceforge.vrapper.vim.register.RegisterManager;
/**
* When you're in InsertMode, you can hit Ctrl+R and it will ask for the
@@ -51,6 +52,12 @@ protected AbstractCommandParser createParser() {
return new PasteRegisterParser(editorAdaptor);
}
+ public static void pasteLastInsert(EditorAdaptor editorAdaptor) {
+ //paste the ". register without actually entering PasteRegisterMode
+ PasteRegisterParser parser = (new PasteRegisterMode(editorAdaptor)).new PasteRegisterParser(editorAdaptor);
+ parser.parseAndExecute("\"", RegisterManager.REGISTER_NAME_INSERT);
+ }
+
private class PasteRegisterParser extends AbstractCommandParser {
public PasteRegisterParser(EditorAdaptor vim) {
@@ -85,6 +92,7 @@ public Command parseAndExecute(String first, String command) {
if(text.length() > 0) {
TextContent content = editor.getModelContent();
int offset = editor.getCursorService().getPosition().getModelOffset();
+ //different from PasteOperation! it does length() - 1
int position = offset + text.length();
content.replace(offset, 0, text);
Position destination = editorAdaptor.getCursorService().newPositionForModelOffset(position);
Please sign in to comment.
Something went wrong with that request. Please try again.