Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore cursor position after surround-change operation #2

Closed
sunaku opened this issue Dec 25, 2009 · 1 comment
Closed

restore cursor position after surround-change operation #2

sunaku opened this issue Dec 25, 2009 · 1 comment

Comments

@sunaku
Copy link
Contributor

sunaku commented Dec 25, 2009

Hello,

I use the surround-change operation (not sure if that is the official name) to switch between single and double quotes for strings in my Ruby program.

While trying to make shortcuts for the aforementioned operation, I noticed that the cursor moves to the beginning of the operand text after the operation. I tried to solve this by restoring Vim's default "position before the latest jump" marker (see :help '') as suggested by a person named "elik" in the #vim IRC channel:

nmap <leader>' cs"' ``
nmap <leader>" cs'" ``

But this did not work. Instead, I had to use an explicit temporary (I hope) marker:

" switch between single and double quotes (surround plugin)
"
" NOTE: we explictly set a temporary marker (z) and restore it after
"       the surround operation because the surround plugin does not
"       restore the cursor position after the surround operation; it
"       leaves the cursor at the opening quote of the operand instead!
"
nmap <leader>' mz cs"' `z
nmap <leader>" mz cs'" `z

Perhaps surround.vim is interfering with this default Vim marker?

Thanks for your consideration.

@tpope
Copy link
Owner

tpope commented Mar 7, 2010

As the name implies, the "position before the latest jump" marker only applies to jumps like pageup/pagedown and searching. Surrounding isn't a jump. You can save to this marker explicitly though with `m`` if you want to avoid using a temporary marker.

SIde note: I just lost all respect for markdown trying to actually typeset two adjacent backticks as inline code.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants