1

I found the following execute command to be useful in vim:

:execute "normal! mqA;\<esc>`q"

it goes to normal mode, then it makes a mark "q" at cursor position, goes to end of the line and adds a semicolon ";", then it goes to normal mode again and returns to the original cursor position.

How could I map all this command to a key called "scc"?

I have tried:

imap scc <Esc>:execute "normal! mqA;\<esc>`q"<CR> 

however it didn't work. Thanks.

2 Answers 2

4

You don't need :execute - normal, you can simply do (and use the "noremap" form):

inoremap scc <Esc>mqA;<Esc>`q

But your map keys are not very good chosen(?), try e.g. <F3> for function key 3.

Sign up to request clarification or add additional context in comments.

2 Comments

your are faster. :) I +1 yours and remove mine.
Thanks, sometimes I'm quick :)
2

Others have dealt with the core problem but I should had that, instead of creating an alphabetical mark, you could use a "context mark":

inoremap <something> <Esc>m`A;<Esc>``

Using an alphabetical mark is not wrong, mind you, but I think they are more useful elsewhere.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.