Different behavior between g* and *
Hi, I noticed there is difference between '*' and 'g*', especially when modes are involved. For example, in c-mode when I hit '*' above some variable like 'sample_variable', only 'sample' gets highlighted and searched. However, with 'g*' 'sample_variable' is correctly highlighted.Similar behavior is in lisp-like modes and cases like 'sample-variable'. Is this expected behavior? Just checked vim behavior, and in both cases full variable name is highlighted and searched. Thanks, Sanel
Am 20.02.2014 12:03, schrieb Sanel Zukan:
Hi,
I noticed there is difference between '*' and 'g*', especially when modes are involved. For example, in c-mode when I hit '*' above some variable like 'sample_variable', only 'sample' gets highlighted and searched.
However, with 'g*' 'sample_variable' is correctly highlighted.Similar behavior is in lisp-like modes and cases like 'sample-variable'.
Is this expected behavior? Just checked vim behavior, and in both cases full variable name is highlighted and searched.
Interestingly in my tests it is the other way around, * selecting the whole symbol and g* selecting one part of the word---but only `evil-symbol-word-search` is non-nil. This difference is certainly not expected behaviour (so it's a bug). I'm currently working on some larger modifications in Evil's internal motion stuff. One thing that will (probably) be implemented is the possibility to make 'word' motions work on Emacs 'symbols' rather than Emacs 'words', which is usually closer to Vim. Best regards, Frank
Thanks, Sanel
On Thu, Feb 20, 2014 at 09:51:48PM +0100, Frank Fischer wrote:
Am 20.02.2014 12:03, schrieb Sanel Zukan:
Hi,
I noticed there is difference between '*' and 'g*', especially when modes are involved. For example, in c-mode when I hit '*' above some variable like 'sample_variable', only 'sample' gets highlighted and searched.
However, with 'g*' 'sample_variable' is correctly highlighted.Similar behavior is in lisp-like modes and cases like 'sample-variable'.
Is this expected behavior? Just checked vim behavior, and in both cases full variable name is highlighted and searched.
Here's the reference for g* in vim's builtin documentation for referene: g* Like "*", but don't put "\<" and "\>" around the word. This makes the search also find matches that are not a whole word.
On 02/20/14,Allen Li wrote:
Here's the reference for g* in vim's builtin documentation for referene:
g* Like "*", but don't put "\<" and "\>" around the word. This makes the search also find matches that are not a whole word.
Thanks for explanation; I consulted Vim help too, but documentation part was made sense to me after I noticed rain/rainbow example explained on http://vim.wikia.com/wiki/Searching. Best, Sanel
On 02/20/14,Frank Fischer wrote:
Interestingly in my tests it is the other way around, * selecting the whole symbol and g* selecting one part of the word---but only `evil-symbol-word-search` is non-nil. This difference is certainly not expected behaviour (so it's a bug).
Ahh, in my case 'evil-symbol-word-search' was nil (which is AFAIK default); after setting it to 't', it reversed behavior which is like in Vim. I'm curious, why 'evil-symbol-word-search' wasn't set to t by default?
I'm currently working on some larger modifications in Evil's internal motion stuff. One thing that will (probably) be implemented is the possibility to make 'word' motions work on Emacs 'symbols' rather than Emacs 'words', which is usually closer to Vim.
This will be highly welcomed :) Will this make completion (C-n/C-p) smarter? I noticed if I have e.g. 'foo' (foo inside quotes), Evil doesn't know to complete foo, unless word is started with quote (e.g. 'fo).
Best regards, Frank
Best, Sanel
Am 21.02.2014 23:11, schrieb Sanel Zukan:
On 02/20/14,Frank Fischer wrote:
Interestingly in my tests it is the other way around, * selecting the whole symbol and g* selecting one part of the word---but only `evil-symbol-word-search` is non-nil. This difference is certainly not expected behaviour (so it's a bug).
Ahh, in my case 'evil-symbol-word-search' was nil (which is AFAIK default); after setting it to 't', it reversed behavior which is like in Vim. I'm curious, why 'evil-symbol-word-search' wasn't set to t by default?
Historical reasons and consistency: a word is what w or e move over, and what the [:word:] regexp matches. That might not be a good choice, however ;)
I'm currently working on some larger modifications in Evil's internal motion stuff. One thing that will (probably) be implemented is the possibility to make 'word' motions work on Emacs 'symbols' rather than Emacs 'words', which is usually closer to Vim.
This will be highly welcomed :) Will this make completion (C-n/C-p) smarter? I noticed if I have e.g. 'foo' (foo inside quotes), Evil doesn't know to complete foo, unless word is started with quote (e.g. 'fo).
I'm not sure, probably not without additional steps (IIRC Evil just calls `dabbrev-expand`). However, completion is somehow out of the scope of Evil. There are several completion packages out there and some of them might work much better than the current one (just bind the corresponding functions to C-p and C-n). Best regards, Frank
participants (3)
-
Allen Li -
Frank Fischer -
Sanel Zukan