Sunday, May 26, 2024

Re: problem to create a shortcut

For the record, the following worked for me:

```
function GotoMark(str) abort
  execute printf('/MARK_%s', a:str)
endfunction

command -nargs=* Gm call GotoMark(<f-args>)

" test
new | put =['abc', 'MARK_X', 'def']
Gm X
```

Note that `:/{pattern}` is a shorter way of saying `:global/{pattern}/` if all you care about is the side-effect of moving the cursor; technically, the latter moves to the last occurrence of the pattern while `:/` moves to the next occurrence (with wrap-around controlled by the 'wrapscan' option).

--
--
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/2025f52d-65f1-40f6-8a1e-c5d01be15c63n%40googlegroups.com.

No comments:

Post a Comment