Monday, June 3, 2013

Re: insert mode mapping to move to a column

On Mon, Jun 3, 2013 at 10:38 AM, Ben Fritz <fritzophrenic@gmail.com> wrote:
>
> On Monday, June 3, 2013 1:31:08 AM UTC-5, sinbad wrote:
> > On Thursday, May 30, 2013 10:59:52 AM UTC+5:30, sinbad wrote:
> >
> > set ve=all is little annoying to be set
> > all the time, at least i'm not use to it.
> > how can i temporarily set and unset it.
> > should i do it in a function. i tried the
> > following it doesn't work.
> >
> > inoremap ,s <C-O>:call Top_align()<CR>
> >
> > fun! Top_align()
> > set ve=all
> > exec "<Up><C-Right><Down>"
> > set ve=
> > endfun
>
> One reason this won't work is because you used "exec" when you meant "normal". The :exec command executes ex commands, not commands as typed.
>
> I was thinking an expression map might be better (:help :map-<expr>) but I couldn't quickly figure out a good way to make it work.

Also, if you use :normal, you can't use <Up> as is as that would
behave as if you'd typed four keys: <, U, p and >. You'd have to
actually do something like :normal <c-v><up> (that's hitting a
control-V to get a literal character and then hitting UP to actually
have it insert the character code for the up key).

Your best bet may be something like

:execute "normal \<up>\<c-right>\<down>"

Salman

--
--
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: