Saturday, May 25, 2024

problem to create a shortcut

the following  code does NOT work.
The goal is to use a shortcut like "Gmx" to jump to a mark "MARK_X" in the test.
to make it more useable U want to create a function with the last string (in the case above "X" as argument.

question: HOW I write a "goto-mark" function in vim?

" old → works
command! -nargs=0 Gmu    silent g/MARK_U\>/
command! -nargs=0 Gmv    silent g/MARK_V\>/
command! -nargs=0 Gmw    silent g/MARK_W\>/
command! -nargs=0 Gmx    silent g/MARK_X\>/
command! -nargs=0 Gmy    silent g/MARK_Y\>/
command! -nargs=0 Gmz    silent g/MARK_Z\>/

" new → doesn't work
function GotoMark(str)
  "execute("g/MARK_" . a:str . "/")
  "execute("g/MARK_" . "PN" . "/")
  g/MARK_PN/
endfunction

command! -nargs=1 Gm     silent call GotoMark(<f-args>)
"command! -nargs=1 GM     silent execute("g/MARK_" . string(<f-args>) . "/")
"command! -nargs=1 GM     silent g/MARK_PN/

--
--
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/a9f7041d-2265-42c5-9802-3b5463237381n%40googlegroups.com.

No comments:

Post a Comment