t9md / atom-vim-mode-plus

vim-mode improved
https://atom.io/packages/vim-mode-plus
MIT License
1.4k stars 111 forks source link

Add the ability to go to . mark using `. #822

Open dionyziz opened 7 years ago

dionyziz commented 7 years ago

The . mark stores the last edited line. You should be able to go to it using the keyboard shortcut backtick-dot. This is a very useful feature because of the following use case: If I am typing some code and want to look something up, I will typically search for it using / or ?. Once I'm done finding what I'm looking for or yanking some portions I needed, I want to go back to where I was last editing.

Check list

t9md commented 7 years ago

Vmp not suppurting . mark currently.

But it have support for backtick mark to jump back previous cursor position in editor.

g i to move to last insert-mode position.

Also my cursor-history package allowes me cursor history within and across editor.

Why I rarely use mark in pure-Vim and vmp is because I use ctrl-i or ctrl-o to move go/back cursor-history(jumplist in viim's term).

I understand . mark support is reasonable request but not high priority for me for the reason I explained above.

dionyziz commented 7 years ago

Thanks for your answer. I understand this is a low priority now. If you get to implementing it, please let me know, it would be appreciated.

Also, if I wanted to go ahead and implement something like that, where would you recommend that I start?

dylnmc commented 7 years ago

if you press ctrl+. you bring up the keybinding resolver. Now when you press gi it will show you:

'g i': 'vim-mode-plus:insert-at-last-insert'

so now, you can cd .atom/packages/vim-mode-plus then grep -r insert-at-last .. This shows

./lib/command-table.coffee:  commandName: "vim-mode-plus:insert-at-last-insert"
./keymaps/vim-mode-plus.cson:  'g i': 'vim-mode-plus:insert-at-last-insert'

So, maybe that's a good place to start.

disclaimer: I have never worked on any atom packages or on vim-mode-plus.


Maybe it would be wise for you (and myself) to read up on tutorials for creating atom packages:

  1. building your first atom plugin

  2. some dude's blog

t9md commented 7 years ago

@dionyziz

The keystroke ` . is just jumping to . mark. So this request is to support . mark. What you need to do is to save/update . mark location with changed position. Since change is made in several way(via operator, via inserting text), deciding when to update this mark is most difficult part to support this feature.

As . mark of vim-help describe..

'.  `.          To the position where the last change was made.  The
            position is at or near where the change started.
            Sometimes a command is executed as several changes,
            then the position can be near the end of what the
            command changed.  For example when inserting a word,
            the position will be on the last character.

            To jump to older changes use |g;|.

            {not in Vi}

For me, this explanation is ambiguous. I cannot understand what's the diff from [, ] mark which contains changed location.

vmp have already [, ] and ^ marks which are auto updated at special timing. search @vimState.mark.set( for src code to understand how it's updated. I think even those mark update timing/correctness is NOT perfect, need to be improved.