[gnome-builder] vim: add underscore motion (_) to normal mode
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vim: add underscore motion (_) to normal mode
- Date: Sun, 15 Nov 2015 22:57:29 +0000 (UTC)
commit 66fce5869e76f4635f0ba1c45589f5cba03c1734
Author: Sebastien Lafargue <slafargue gnome org>
Date: Sun Nov 15 23:56:22 2015 +0100
vim: add underscore motion (_) to normal mode
data/keybindings/vim.css | 6 ++++++
libide/ide-source-view-movements.c | 14 +++++++++++++-
2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index ec80a54..a8de896 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -393,6 +393,12 @@
"clear-count" () };
bind "asciicircum" { "movement" (first-nonspace-char, 0, 1, 0)
"clear-count" () };
+
+ /* this is a count - 1 motion, we handle this specific case in C code */
+ bind "underscore" { "movement" (next-line, 0, 1, 1)
+ "movement" (first-nonspace-char, 0, 1, 0)
+ "clear-count" () };
+
bind "dollar" { "movement" (last-char, 0, 1, 0)
"clear-count" () };
bind "bar" { "movement" (nth-char, 0, 1, 1)
diff --git a/libide/ide-source-view-movements.c b/libide/ide-source-view-movements.c
index 67e9b21..e808987 100644
--- a/libide/ide-source-view-movements.c
+++ b/libide/ide-source-view-movements.c
@@ -1958,6 +1958,7 @@ _ide_source_view_apply_movement (IdeSourceView *self,
Movement mv = { 0 };
GtkTextBuffer *buffer;
GtkTextMark *insert;
+ gint min_count;
gsize i;
g_return_if_fail (IDE_IS_SOURCE_VIEW (self));
@@ -1981,6 +1982,17 @@ _ide_source_view_apply_movement (IdeSourceView *self,
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self));
insert = gtk_text_buffer_get_insert (buffer);
+ /* specific processing for underscore motion */
+ if (g_str_has_suffix (command_str->str, "_"))
+ {
+ min_count = 0;
+ --count;
+ }
+ else
+ {
+ min_count = 1;
+ }
+
mv.self = self;
mv.target_offset = target_offset;
mv.type = movement;
@@ -2117,7 +2129,7 @@ _ide_source_view_apply_movement (IdeSourceView *self,
case IDE_SOURCE_VIEW_MOVEMENT_NEXT_LINE:
mv.ignore_target_offset = TRUE;
mv.ignore_select = TRUE;
- for (i = MAX (1, mv.count); i > 0; i--)
+ for (i = MAX (min_count, mv.count); i > 0; i--)
ide_source_view_movements_next_line (&mv);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]