[gtksourceview] vim: map textwidth/tw to right-margin-position
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] vim: map textwidth/tw to right-margin-position
- Date: Sun, 28 Nov 2021 18:29:15 +0000 (UTC)
commit f5968e7802e4a7e3379eb47df735de44fe05a862
Author: Christian Hergert <chergert redhat com>
Date: Sat Nov 27 18:07:55 2021 -0600
vim: map textwidth/tw to right-margin-position
gtksourceview/vim/gtksourcevimcommand.c | 12 ++++++++++++
testsuite/test-vim-input.c | 1 +
2 files changed, 13 insertions(+)
---
diff --git a/gtksourceview/vim/gtksourcevimcommand.c b/gtksourceview/vim/gtksourcevimcommand.c
index b923555d..efe14b04 100644
--- a/gtksourceview/vim/gtksourcevimcommand.c
+++ b/gtksourceview/vim/gtksourcevimcommand.c
@@ -1178,6 +1178,18 @@ gtk_source_vim_command_set (GtkSourceVimCommand *self)
gtk_source_view_set_indent_width (view, n);
}
}
+ else if (g_str_has_prefix (part, "tw=") ||
+ g_str_has_prefix (part, "textwidth="))
+ {
+ const char *sw = strchr (part, '=') + 1;
+ int n;
+
+ if (parse_number (sw, &n))
+ {
+ if (n >= 1 && n <= 1000)
+ gtk_source_view_set_right_margin_position (view, n);
+ }
+ }
else if (g_str_equal (part, "et") ||
g_str_equal (part, "expandtab"))
{
diff --git a/testsuite/test-vim-input.c b/testsuite/test-vim-input.c
index 0bae218c..7423556f 100644
--- a/testsuite/test-vim-input.c
+++ b/testsuite/test-vim-input.c
@@ -218,6 +218,7 @@ test_command_bar (void)
run_test ("", ":set ts=0\n", "");
run_test ("", ":set ts=-2\n", "");
run_test ("", ":set ts=33\n", "");
+ run_test ("", ":set tw=100\n", "");
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]