Wednesday, October 30, 2013

Re: Smart horizontal cursor positioning (like in an addon for Sublime Text)?

On Tuesday, October 29, 2013 7:40:00 AM UTC-5, Jeraldine Walter wrote:
> Hi,
>
> I want to switch back to gVim after working with ST for a while.
>
> There is an addon for ST, that provides a really slick way of placing the cursor on "the right" position when using cursor up / down after editing text on a line.
>
> This is the link that explains what it does (in a better way):
> http://www.sublimetext.com/forum/viewtopic.php?f=4&t=2529&start=0
>
> Does anyone know if something like this exists for (g)vim as well?
>

I don't know of anything like that, but maybe there is a plugin for it.

However, I do know the '[ mark contains the start position where you last made a change. So, you could do something like this:

function! JumpIfChanged(move)
let movement=a:move " initialize to passed-in command
if line("'[") == line(".")
let movement = "`[".movement " jump to start of change first
endif
return movement
endfun

nnoremap <expr> j JumpIfChanged('j')
nnoremap <expr> k JumpIfChanged('k')

--
--
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.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment