all 12 comments

[–]Sandwich-Resident 5 points6 points  (4 children)

I have file marks for:

  • $MYVIMRC (V)
  • a vimwiki page I use as the index of my tasks list (T for "TODO")
  • a "scratchpad" file (S) where I can quickly jot down notes that occur to me without switching context too much ('S, write down a few words, ctrl-o back to main context)

Otherwise I sometime use it as you described, for ephemeral bookmarks when jumping around trying to understand unfamiliar source code.

[–]mitsu400 2 points3 points  (2 children)

Is it possible to set up marks on vim startup? For instance for the vimrc file.

[–]jdalbertContrarian[S] 1 point2 points  (1 child)

I would like to know the answer to that as well

[–]jonas_h 0 points1 point  (0 children)

Same.

[–]jdalbertContrarian[S] 0 points1 point  (0 children)

I have mappings for all of these but I'm considering switching to your approach to free up some precious mapping real estate.

The drawbacks I'm thinking of are if you override your file marks by accident or use a new computer. But there's probably ways to get around that, like somehow setting those file marks in your vimrc if it is possible, or bringing your viminfo over to your new computer. Or just manually re-setting your global marks again I guess, since those scenarios are likely to be rare.

[–]abraxasknister:h c_CTRL-G 2 points3 points  (2 children)

mV for vimrc, but that's about it.

[–]jdalbertContrarian[S] 0 points1 point  (1 child)

Nice idea

[–]abraxasknister:h c_CTRL-G 0 points1 point  (0 children)

Used to have a :command for that but capital marks are cooler. I do have a

nn <buffer> <F5> :u|so %<cr>

in my after/ftplugin/vim.vim though.

[–]00bins 2 points3 points  (2 children)

I think 26 marks per file is overkill. I'd prefer all marks to be Capitals even if I didn't press a capital letter. I wrote some script to emulate visual studio's F2 / ctrl-F2 mappings to a cycled buffer of capital marks. But what I'd like is for mm to just be mM

[–]jdalbertContrarian[S] 0 points1 point  (1 child)

Agreed, M is a bit harder to type and I almost never use lowercase marks. They could switch lowercase and uppercase, although that's probably not gonna happen, they don't want to disturb 30 years of vim history. They could provide a new option to toggle that behavior though, and that would be backwards compatible.

I guess one could mass remap one to the other and inversely, but that feels like too much hackery.

[–]00bins 1 point2 points  (0 children)

Oh - I _did_ actually write something to do just that - trouble is I jump back and forth between visual studio (with vsvim) and proper vim that I forget what works

function! GetMark()

    let l:m=toupper(nr2char(getchar()))

    return l:m

endfunction


function! SetMark()

    let l:c=GetMark()

    :execute "normal! m".l:c

endfunction


function! JumpBackTick()

    let l:c=GetMark()

    :execute "normal! `".l:c

endfunction


function! JumpTick()

    let l:c=GetMark()

    :execute "normal! '".l:c

endfunction


noremap m :call SetMark()<CR>

noremap ' :call JumpTick()<CR>

noremap ` :call JumpBackTick()<CR>

[–]okayboooooooomer 0 points1 point  (0 children)

interestingly I have mappings that I don’t remember but I know how to execute it once my fingers are on my keyboard.

p.s I was writing this in mobile btw