[gnome-builder] vim: Support linewise motions



commit 0aa48ed8ba71cacbbdc15ecc784d032060cd6bfb
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Oct 5 00:08:22 2014 +0200

    vim: Support linewise motions
    
    Motions can be either character- or linewise when used as modifiers
    to a command. The commands will operate on entire lines when the
    motion is linewise, e.g. 'dj' deletes two lines (rather than from
    the cursor position to to the same column on the following line).
    Add another flag to support this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737959

 src/editor/gb-editor-vim.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 83b41f5..2c82574 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -93,6 +93,7 @@ typedef enum
   GB_EDITOR_VIM_COMMAND_FLAG_REQUIRES_MODIFIER = 1 << 0,
   GB_EDITOR_VIM_COMMAND_FLAG_VISUAL            = 1 << 1,
   GB_EDITOR_VIM_COMMAND_FLAG_MOTION_EXCLUSIVE  = 1 << 2,
+  GB_EDITOR_VIM_COMMAND_FLAG_MOTION_LINEWISE   = 1 << 3,
 } GbEditorVimCommandFlags;
 
 /**
@@ -1218,7 +1219,11 @@ gb_editor_vim_apply_motion (GbEditorVim *vim,
   if (!cmd || (cmd->type != GB_EDITOR_VIM_COMMAND_MOVEMENT))
     return;
 
-  gb_editor_vim_select_char (vim);
+  if (cmd->flags & GB_EDITOR_VIM_COMMAND_FLAG_MOTION_LINEWISE)
+    gb_editor_vim_select_line (vim);
+  else
+    gb_editor_vim_select_char (vim);
+
   cmd->func (vim, count, '\0');
 
   if ((cmd->flags & GB_EDITOR_VIM_COMMAND_FLAG_MOTION_EXCLUSIVE))
@@ -3478,7 +3483,7 @@ gb_editor_vim_class_init (GbEditorVimClass *klass)
                                         GB_EDITOR_VIM_COMMAND_MOVEMENT,
                                         gb_editor_vim_cmd_forward_word_end);
   gb_editor_vim_class_register_command (klass, 'G',
-                                        GB_EDITOR_VIM_COMMAND_FLAG_NONE,
+                                        GB_EDITOR_VIM_COMMAND_FLAG_MOTION_LINEWISE,
                                         GB_EDITOR_VIM_COMMAND_MOVEMENT,
                                         gb_editor_vim_cmd_goto_line);
   gb_editor_vim_class_register_command (klass, 'g',
@@ -3498,11 +3503,11 @@ gb_editor_vim_class_init (GbEditorVimClass *klass)
                                         GB_EDITOR_VIM_COMMAND_CHANGE,
                                         gb_editor_vim_cmd_insert);
   gb_editor_vim_class_register_command (klass, 'j',
-                                        GB_EDITOR_VIM_COMMAND_FLAG_NONE,
+                                        GB_EDITOR_VIM_COMMAND_FLAG_MOTION_LINEWISE,
                                         GB_EDITOR_VIM_COMMAND_MOVEMENT,
                                         gb_editor_vim_cmd_move_down);
   gb_editor_vim_class_register_command (klass, 'k',
-                                        GB_EDITOR_VIM_COMMAND_FLAG_NONE,
+                                        GB_EDITOR_VIM_COMMAND_FLAG_MOTION_LINEWISE,
                                         GB_EDITOR_VIM_COMMAND_MOVEMENT,
                                         gb_editor_vim_cmd_move_up);
   gb_editor_vim_class_register_command (klass, 'l',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]