Tuesday, November 1, 2022

Lowest number of keystrokes to modify part of a line

Hi,

I'm Italian hence knowingly lazy.

I have a file that I use as a log for my morse learning.

The structure is:


qrq Wed 26/10 11:18
Groups Thu 27/10 20:00
WT Thu 27/10 21:37
qrq2 Thu 27/10 10:24
morse Fri 28/10 20:17
qrq Fri 28/10 22:15
Groups Sat 29/10 19:46
WT Sat 29/10 21:21
qrq2 Sun 30/10 18:48
morse Sun 30/10 22:07[x]
qrq Mon 31/10 10:19
Groups Mon 31/10 19:42

See that [x]? That's where the cursor is.

I want to modify the line just below that (starting with qrq), remove
that timestamp and put a new one.

The timestamp is mapped to 'mydate' :

$ grep mydate .vim/vimrc
iabbrev mydate <C-R>=strftime("%a %d/%m/%Y")

I want to find the lowest number of keystrokes I need to modify that
timestamp.

What I'm doing at the moment is:

[w] [w] [R] cwd [:wq]

That is: one word forward, one word forward, Replace to the end; save
and quit, but I wonder if there is a lazier and more elegant way.

M. v. g.


--
Ottavio Caruso

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/fcf39be5-f471-beed-9297-e1e653c22342%40yahoo.com.

Re: vim airline too consumption starting time

On Tue, 1 Nov 2022 11:42:43 +0100
"'Marek Stepanek' via vim_use" <vim_use@googlegroups.com> wrote:

> ps: should I open an own thread perhaps?

Yes.

--
Enan

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20221101164905.309524df%40cirdan.

Re: vim airline too consumption starting time

Bonjour Nicolas,

I don't want to highjack your thread. But I have the same problem: vimr or neovim are starting for the first time after restart of my macOS very slowly (more than 20 seconds). But the command `vimr --startuptime vimr.log` does not work in my shell. Same with `neovim` and also with `sudo` ... The command works seamlessly with vim; but here I have no starting problems, because vim has nearly no plugins. 

Perhaps could somebody could help here?

marek

ps: should I open an own thread perhaps? 


On 31. Oct 2022, at 03:44, Nicolas <nivaemail@gmail.com> wrote:

Removing airline in th e benefit of powerline, no comment.
Nicolas



Monday, October 31, 2022

Re: pb with nnoremap an imported vim9 defnot loaded

Hi Salman,

I copy paste this from $MYVIMRC
nnoremap n n<ScriptCmd> thatHelp.HLNext(80)<CR>
nnoremap N N<ScriptCmd> thatHelp.HLNext(80)<CR>

it's in reference to another post https://groups.google.com/g/vim_use/c/_U2ne7QlOWc/m/7pUuGJ2BAwAJ.

I cannot or don"'t know how to test it through command line because it calls an imported vim9 def func.


Le lundi 31 octobre 2022 à 15:16:52 UTC+1, Salman Halim a écrit :
Did you type the mappings in the email message or did you copy/paste them from your VIMRC? Are you able to get the mappings to work if you copy/paste them onto the command-line after Vim has started? The primary problem I can see with the mappings is that you have them defined as n<ScriptCmd> instead of just n:

...n<ScriptCmd> th... defines a mapping for n<ScriptCmd>
...n <ScriptCmd>th... defines a mapping for n that then executes a script command and is probably what you want

As an aside, the function you defined is technically correct, though inefficient in a few things, but that's not likely to be the cause of your woes.

On Mon, Oct 31, 2022 at 1:43 AM Nicolas <niva...@gmail.com> wrote:
Hi,


Using this def func to blink searched word I mapped it in $MYVIMRC as this but it seems that at vim startup, the nnoremap is not defined, no call occurs.

Thankyou for help
Nicolas

$MYVIMRC
import autoload './vimfiles/plugged/foobar.vim'
as thatHelp

nnoremap n   n<ScriptCmd> thatHelp.HLNext(80)<CR>
nnoremap N   N<ScriptCmd> thatHelp.HLNext(80)<CR>



foobar.vim
export def HLNext(blinktime: number): number
    # https://www.youtube.com/watch?v=aHm36-na4-4#t6m36s

  echomsg 'export def HLNext has been called.'

  highlight BlackOnBlack guibg=black guifg=#3c4c55 ctermbg=black ctermfg=black

  var [bufnum: number, lnum: number, col: number, off: number] = getpos('.')
  var target_pat: string = '\k*\%#\k*'
  target_pat = '\%#' .. @/
  target_pat = '\k*\%#\k*'
  var blinks: number = 3

  var sleep_duration: number = ( blinktime / (2 * blinks) )->float2nr()
  var sleep_cmd: string = 'sleep ' .. sleep_duration .. 'm'


  for n in range(1, blinks)

    # echomsg n
    var hide: number = matchadd('BlackOnBlack', target_pat, 101)
    redraw
    exec sleep_cmd
    matchdelete(hide)
    redraw
    exec sleep_cmd

  endfor

  return 0

enddef



--
--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/f6861e1f-9783-49b6-b151-b6f1625e6ce5n%40googlegroups.com.


--
 
Salman

I, too, shall something make and glory in the making.

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/d837331e-b4c2-42cc-836c-16b4c867cbf2n%40googlegroups.com.

Re: pb with nnoremap an imported vim9 defnot loaded

Did you type the mappings in the email message or did you copy/paste them from your VIMRC? Are you able to get the mappings to work if you copy/paste them onto the command-line after Vim has started? The primary problem I can see with the mappings is that you have them defined as n<ScriptCmd> instead of just n:

...n<ScriptCmd> th... defines a mapping for n<ScriptCmd>
...n <ScriptCmd>th... defines a mapping for n that then executes a script command and is probably what you want

As an aside, the function you defined is technically correct, though inefficient in a few things, but that's not likely to be the cause of your woes.

On Mon, Oct 31, 2022 at 1:43 AM Nicolas <nivaemail@gmail.com> wrote:
Hi,


Using this def func to blink searched word I mapped it in $MYVIMRC as this but it seems that at vim startup, the nnoremap is not defined, no call occurs.

Thankyou for help
Nicolas

$MYVIMRC
import autoload './vimfiles/plugged/foobar.vim'
as thatHelp

nnoremap n   n<ScriptCmd> thatHelp.HLNext(80)<CR>
nnoremap N   N<ScriptCmd> thatHelp.HLNext(80)<CR>



foobar.vim
export def HLNext(blinktime: number): number
    # https://www.youtube.com/watch?v=aHm36-na4-4#t6m36s

  echomsg 'export def HLNext has been called.'

  highlight BlackOnBlack guibg=black guifg=#3c4c55 ctermbg=black ctermfg=black

  var [bufnum: number, lnum: number, col: number, off: number] = getpos('.')
  var target_pat: string = '\k*\%#\k*'
  target_pat = '\%#' .. @/
  target_pat = '\k*\%#\k*'
  var blinks: number = 3

  var sleep_duration: number = ( blinktime / (2 * blinks) )->float2nr()
  var sleep_cmd: string = 'sleep ' .. sleep_duration .. 'm'


  for n in range(1, blinks)

    # echomsg n
    var hide: number = matchadd('BlackOnBlack', target_pat, 101)
    redraw
    exec sleep_cmd
    matchdelete(hide)
    redraw
    exec sleep_cmd

  endfor

  return 0

enddef



--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/f6861e1f-9783-49b6-b151-b6f1625e6ce5n%40googlegroups.com.


--
 
Salman

I, too, shall something make and glory in the making.

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEd4hGKmRdLjwpDzFc27ntXrryff-rZ4w4gH1jubzCnqdw%40mail.gmail.com.

Sunday, October 30, 2022

pb with nnoremap an imported vim9 defnot loaded

Hi,


Using this def func to blink searched word I mapped it in $MYVIMRC as this but it seems that at vim startup, the nnoremap is not defined, no call occurs.

Thankyou for help
Nicolas

$MYVIMRC
import autoload './vimfiles/plugged/foobar.vim'
as thatHelp

nnoremap n   n<ScriptCmd> thatHelp.HLNext(80)<CR>
nnoremap N   N<ScriptCmd> thatHelp.HLNext(80)<CR>



foobar.vim
export def HLNext(blinktime: number): number
    # https://www.youtube.com/watch?v=aHm36-na4-4#t6m36s

  echomsg 'export def HLNext has been called.'

  highlight BlackOnBlack guibg=black guifg=#3c4c55 ctermbg=black ctermfg=black

  var [bufnum: number, lnum: number, col: number, off: number] = getpos('.')
  var target_pat: string = '\k*\%#\k*'
  target_pat = '\%#' .. @/
  target_pat = '\k*\%#\k*'
  var blinks: number = 3

  var sleep_duration: number = ( blinktime / (2 * blinks) )->float2nr()
  var sleep_cmd: string = 'sleep ' .. sleep_duration .. 'm'


  for n in range(1, blinks)

    # echomsg n
    var hide: number = matchadd('BlackOnBlack', target_pat, 101)
    redraw
    exec sleep_cmd
    matchdelete(hide)
    redraw
    exec sleep_cmd

  endfor

  return 0

enddef



--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/f6861e1f-9783-49b6-b151-b6f1625e6ce5n%40googlegroups.com.

Re: How to incude '/' in search(find) string on the fly

Glad you found a solution. I've just become really accustomed to escaping the slash so don't even think about it any more. 

Salman

On Sun, Oct 30, 2022, 07:39 'Carl Ponder US' via vim_use <vim_use@googlegroups.com> wrote:
It looks like this is giving me what I want:
```

:nnoremap / :call SlashEscape()<CR>/
:function SlashEscape()
:    cnoremap <CR> <C-\>eescape(getcmdline(), '/')<CR><CR>:cunmap <lt>CR><CR>
:endfunction

:nnoremap ? :call QuestionEscape()<CR>?
:function QuestionEscape()
:    cnoremap <CR> <C-\>eescape(getcmdline(), '?')<CR><CR>:cunmap <lt>CR><CR>
:endfunction
```
posted here:

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/38b347c1-6fc2-45c2-b873-3b6eb8a0b9e3n%40googlegroups.com.

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEf2USDtmQ5e_Kt0k0E8NQDnuAT%2B7%3DM-KX_BnL7O%2Bfc%3D%2BA%40mail.gmail.com.