Re: [dev] [ANNOUNCE] vis-0.1: first release of a vim-like editor
Marc André Tanner wrote:
> > Maybe a global default 'syntax highlighter' applied regardless of file type
> > could do the job?
>
> Maybe, yes. However you probably want these features in combination with
> regular syntax highlighting. Maybe a layered approach would somehow work
Thats what I meant. It would basically run independently of the filetype
specific syntax highlighting, probably before it and create the
backgrounds/visual replacements for whitespace, the colorcolumn, another
background for all lines with a cursor and maybe even the line numbers. One
could also add such a global highlighter running after the filetype specific one
to override some stuff. First things that come to mind would be highligthing the
searchterm (hlsearch) or the word, the cursor is currently above.
> > Still does not work. After enabling one of the `show` settings, I am unable
> > to reset it again. I have to restart vis.
>
> Strange, seems to work fine here.
Okay, I got the issue. `parse_bool` is called with `0\n` as first argument. The
newline character should not be there for the intended behaviour. I also managed
to unset the setting by _not_ using the history. So it seems to be a bug with
the history imlementation. To reproduce it, `:set show tabs` and then
`:<Up><End>0<Delete><Return>`. I don't know the best way to fix it, but it would
be possible to strip the newline from within the `cmd_set` function.
> The vis way of doing this would be an alias to `<vis-operator-shift-right>gv`
Ah right, I see it's used for `~` now. Could you add this mapping to the
bindings_visual and bindings_visual_line in config.def.h?
> > I also was surprised, `\<view\>` works as it should. I propose to change
> > CURSOR_SEARCH_WORD_… to use `\<WORD\>` as regex instead of just `WORD` to
> > achieve the same functionality as in vim.
>
> Yes I agree.
This patch for vis-motions.c works for me:
_AT_@ -1,3 +1,4 @@
+#include <stdio.h>
#include <string.h>
#include <regex.h>
#include "vis-core.h"
_AT_@ -17,8 +18,12 @@ static char *get_word_at(Text *txt, size_t pos) {
/** motion implementations */
static size_t search_word_forward(Vis *vis, Text *txt, size_t pos) {
+ char expr[512];
char *word = get_word_at(txt, pos);
- if (word && !text_regex_compile(vis->search_pattern, word, REG_EXTENDED))
+ if (!word)
+ return pos;
+ snprintf(expr, sizeof(expr), "\\<%s\\>", word);
+ if (!text_regex_compile(vis->search_pattern, expr, REG_EXTENDED))
pos = text_search_forward(txt, pos, vis->search_pattern);
free(word);
return pos;
Should be adapted for search_word_backward accordingly. I also noticed, that the
search order is not permanently stored. When using `#` or `?`, I am used to
still search backwards when pressing `n` and forwards when pressing `N`.
> > - Could you replace the `0` in relativenumber mode with the actual line
> > number?
>
> should be implemented now.
Thanks.
> > > The fix is to adjust the cursor position before performing the subsequent
> > > motions similarly to how it is done for text objects with a count.
> >
> > Hm, maybe changing the imlementation of TO_…/TILL_… to ignore the one
> > character under/after the cursor is less of a workaround?
>
> But this would break the entering `tX` multiple times use case ...
The only stuff that "breaks" with the following patch to vis-motions.c is when
the cursor is over the `X` in `abcabcXdefdef` and you expect `td` or `Tc` to
move the cursor to the last `d` / first `c` in the line. I don't think it's that
useful to don't move the cursor, if you are directly before `d` and want to move
"till" the next `d`. The behaviour I am proposing is nonstandard in vim (but
more consistent imho). Little side-note: The `to` commands can more easily
distinguished from the `till` commands when thinking of them as `find` (`f`
shortcut). They move the cursor above the search char, just like a normal search
would.
_AT_@ -57,7 +62,7 @@ static size_t to(Vis *vis, Text *txt, size_t pos) {
}
static size_t till(Vis *vis, Text *txt, size_t pos) {
- size_t hit = to(vis, txt, pos);
+ size_t hit = to(vis, txt, pos+1);
if (hit != pos)
return text_char_prev(txt, hit);
return pos;
_AT_@ -74,7 +79,7 @@ static size_t to_left(Vis *vis, Text *txt, size_t pos) {
}
static size_t till_left(Vis *vis, Text *txt, size_t pos) {
- size_t hit = to_left(vis, txt, pos);
+ size_t hit = to_left(vis, txt, pos-1);
if (hit != pos)
return text_char_next(txt, hit);
return pos;
--Markus
Received on Sun Jan 17 2016 - 22:18:19 CET
This archive was generated by hypermail 2.3.0
: Sun Jan 17 2016 - 22:24:10 CET