Tuesday, July 18, 2017

Re: set iminsert: why global, not local?

On Tuesday, July 18, 2017 at 10:45:13 PM UTC+3, Christian Brabandt wrote:

> known bug:
> https://groups.google.com/d/msg/vim_dev/HpwZWJojl3E/4zCBH3qWQ5IJ

Thanks, Christian!

Now, having in mind this and also what Tony has said ("setting 'keymap' on a given buffer also sets 'iminsert' to 1 on that same buffer as a side-effect"), I presume the following buffer-local keyboard switcher can be introduced as a workaround:

inoremap <silent> <expr> <S-Tab> &keymap == ""
\ ? '<C-o>:setlocal keymap=russian-jcukenmac<CR>'
\ : '<C-o>:setlocal keymap=<CR>'

Or will there be any problems?

--
R

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Searching limited to syntax groups

On 2017-07-18 15:47, David Fishburn wrote:
> http://www.vim.org/scripts/script.php?script_id=848

Excellent...I look forward to experimenting with it. Thanks!

-tim


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Searching limited to syntax groups



On Tue, Jul 18, 2017 at 1:01 PM, Tim Chase <vim@tim.thechases.com> wrote:
My digging hasn't been able to turn up anything, but I was hoping for
something that would let me easily search just code or comments to
the exclusion of the other.  Something like (imaging a sequence like
"\%syntax{SyntaxID}" but actual flavor/implementation is negotiable)

  /\%syntax{Comment}customer\c

to only search my comments for "customer\c", excluding all of the
instances of "customer" in my codebase.

Anything obvious I overlooked, or does this require deeper scripting
with search() and then sniffing the resulting SynID value?



I wrote this plugin to address this feature:

SrchRplcHiGrp.vim : Search and/or replace based on a syntax highlight group


It supports the 3 types of visual modes (linewise, block and character).

You can either search for something in the correct highlight group, or you can do search and replaces on those same searches.

The web page has examples of usage.

If you run into something it can't do, I am always open to suggestions.

Enjoy.
David


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: set iminsert: why global, not local?

On Di, 18 Jul 2017, RingoRangoRongo wrote:

> Am I missing something, or is it impossible to set iminsert for a specific buffer only, not for Vim globally?

known bug:
https://groups.google.com/d/msg/vim_dev/HpwZWJojl3E/4zCBH3qWQ5IJ


Best,
Christian
--
Ein alter Mann ist ein Kind mit Vergangenheit.
-- Zariko Petan

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: set iminsert: why global, not local?

On Tue, Jul 18, 2017 at 8:34 PM, RingoRangoRongo <9876200@gmail.com> wrote:
> Thanks for your reply, Tony!
>
> 1-2. Then I AM missing something, I assume: http://i.imgur.com/1SqcHwW.gif
> Like, why the Russian keymap — even though set locally via "setlocal iminsert=1" — applies to all buffers?
>
> 3. Well, I seem to understand why exactly this behavior happens ("characters [being] simply typed"). What I don't understand, is how to deal with that? Like, if I want to remap <ESC> in INSERT mode, and also want to keep my arrows working, too, for example?
>

'keymap' is also a buffer-local (not window-local) option, you should
also set it by means of :setlocal. IIRC, setting 'keymap' on a given
buffer also sets 'iminsert' to 1 on that same buffer as a side-effect.

My custom 'statusline' setting displays the b:keymap_name when keymaps
are in use (via the %k item) and at the moment, some windows have
that, others not, so it is definitely possible to set it separately
for different buffers. FWIW, here's the 'statusline' I use:

if has('statusline')
set statusline=%<%f\
%h%m%r%=%k[%{(&fenc==''?&enc:&fenc)}%{(&bomb?',BOM':'')}][U+%04B]\
%-12.(%l,%c%V%)\ %P
endif

If, in a given buffer, 'iminsert' is not set locally the way you want
it, you can toggle it by means of the Ctrl-^ keystroke in Insert mode.
That keystroke is hard to get on my keyboard, so I added the following
to my owncoded keymap before the :loadkeymap line:

if mapcheck("<F8>", "nvoicsxl") == ""
map <F8> :let &l:imi = !&l:imi<CR>
sunmap <F8>
map! <F8> <C-O><F8>
cmap <F8> <C-^>
endif

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: set iminsert: why global, not local?

Thanks for your reply, Tony!

1-2. Then I AM missing something, I assume: http://i.imgur.com/1SqcHwW.gif
Like, why the Russian keymap — even though set locally via "setlocal iminsert=1" — applies to all buffers?

3. Well, I seem to understand why exactly this behavior happens ("characters [being] simply typed"). What I don't understand, is how to deal with that? Like, if I want to remap <ESC> in INSERT mode, and also want to keep my arrows working, too, for example?

--
R

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: set iminsert: why global, not local?

On Tue, Jul 18, 2017 at 6:48 PM, RingoRangoRongo <9876200@gmail.com> wrote:
> Hi,
>
>
> Am I missing something, or is it impossible to set iminsert for a specific buffer only, not for Vim globally?
>
> I mean, I have "set keymap=russian-jcukenmac; set iminsert=0", and if I switch to the Russian keymap via <C-^>, it does affect all open buffers. I tried creating a [conditional] shortcut with "setlocal" but with no success, unfortunately.
>
> Help system suggests remapping <ESC> for INSERT mode like this: "inoremap <ESC> <ESC>:set iminsert=0<CR>" but then another problem arises: in terminal Vim, arrows (and probably not only arrows) stop working in INSERT mode (which is kinda obvious, since they do send <ESC> all the way long: Left is ^[[D, Right is ^[[C, etc). Probably, that's somehow related to timeout settings? Mine are "set timeout timeoutlen=3000 ttimeoutlen=100"
>
> Summing up, my question is if it's possible to limit iminsert to a buffer? Would be grateful for any comments :).

1. 'iminsert' is local to buffer, see :help 'imi'
2.
:setglobal option=value
:setglobal booloption
:setglobal nobooloption
sets only the global default value

:setlocal option=value
:setlocal booloption
:setlocal nobooloption
sets only the local value

:set option=value
:set booloption
:set nobooloption
sets both.

For global-only options, ":setlocal" is not an error, in that case
":set" ":setlocal" and ":setglobal" are synonymous.

3. To tell apart bytes sent as part of keycodes, characters sent as
part of mappings, and characters simply typed, see
:help 'timeout'
:help 'timeoutlen'
:help 'ttimeout'
:help 'ttimeoutlen'

I use
if exists('+timeout')
set timeout timeoutlen=5000 ttimeoutlen=250
endif

Of course, YMMV: use higher values (in milliseconds) if you're a slow
typist or on a slow connection, lower ones if you're impatient.


Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.