-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent auto-close of quote when standing at a word boundary? #129
Comments
Please try the following settings. call lexima#add_rule({'char': '"', 'at': '\%#\s*\w'}) If the cursor ( This rule overrides a built-in rule on |
Thanks! It works for Trial 1
becomes
Trial 2I tried to develop something that would consider the end-of-line case and came up with call lexima#add_rule({'char': '"', 'at': '\%#\s*\w\|\w\%#$'}) This works for all 3 test words. However it does not work to insert an auto-closed quote between words that have >2 spaces between them If the goal is to insert
to
then typing Trial 3Going back to the original formulation of word boundary, I then tried using use that regex feature call lexima#add_rule({'char': '"', 'at': '\%#\(\<\|\>\)'}) This seems to work in both the original case + the insert-between-words case above. To test this out further I opened up a source code file (Ruby) and picked a line having some special characters and decided I wanted to transform
by quoting
This did of course not work becuase special characters are not word boundaries. Trial 4Then I though then about the problem from the other way around: maybe we want to auto-complete double quotes only when there are some spaces or nothing before and after the cursor. This condition negated is when we want to insert only one double quote: call lexima#add_rule({'char': '"', 'at': '\%#\S\|\S\%#'}) So far, this rule seems to actually work for all cases above! :O |
I have been using rules that @erikw suggested, but noticed they don't always work for me. For example, call lexima#add_rule({'char': '"', 'at': '"\S\{-1,}\%#\|\%#\S\{-1,}"'})
call lexima#add_rule({'char': "'", 'at': "'\S\{-1,}\%#\|\%#\S\{-1,}'"})
call lexima#add_rule({'char': '`', 'at': '`\S\{-1,}\%#\|\%#\S\{-1,}`'})
Every rule is analogous and has two parts. One part handles "words" starting and the other "words" ending with given character. This way it looks like a quoting is being closed. Additionally, I have a set of rules for opening brackets, so they won't insert a closing bracket if there is one at the end of the word: call lexima#add_rule({'char': '(', 'at': '\%#\S\{-1,})'})
call lexima#add_rule({'char': '[', 'at': '\%#\S\{-1,}]'})
call lexima#add_rule({'char': '{', 'at': '\%#\S\{-1,}}'}) Examples
|
see also discussion at cohama/lexima.vim#129
I found that with this pattern: call lexima#add_rule({'char': '"', 'at': '"\S\{-1,}\%#\|\%#\S\{-1,}"'}) I won't be able to leave the quote with
|
Hey, first thanks for this nice plugin!
I've been using this for a while and it works mostly good, except for one type of editing that I do actually a multitude times per day. That is the case of adding single or double quotes around an existing word. Let's say that I have the following text line
and my goal is to quote the word
orange
so that the line becomesIf I put my cursor at the the first character of
orange
and enter insert mode withi
and type
"
, lexima.vim will insert a closing quote likeIn this case it is not desirable. Now I have to press backspace, or go to normal mode and press
x
to remove one of the quotes.The same is true for when I will add the closing quote after the word. If I stand at the last character for
orange
and go to insert mode after the cursor witha
and I type
"
, lexima.vim will also auto-close this toAnd once again I have to remove the quote too much.
As this is something that I do many times per day, I would be very keen on finding a way to make lexima.vim not auto-close when being at a word boundary (or maybe there's a better formulated condition here?)!
Is there already a way to configure this, or to re-define the rule for double and single quotes?
Thanks in advance :)
The text was updated successfully, but these errors were encountered: