Map Suspend Function

0 views
Skip to first unread message

Derek Litz

unread,
Dec 18, 2008, 3:51:07 PM12/18/08
to vim...@googlegroups.com

Hey I'm trying to map ^Z to save and then suspend.

:map ^Z :w<CR>^Z

I think I've got it right because I tried replacing the ^Z on the right side
and it works perfectly. Problem is with anything I've put before ^Z it
repeats infinity. Luckily this was just the w command at first, but was a
little dangerous when I had to interrupt a save to get out of the save file
infinite loop...

Any ideas?
--
View this message in context: http://www.nabble.com/Map-Suspend-Function-tp20987147p20987147.html
Sent from the Vim - General mailing list archive at Nabble.com.

Ben Schmidt

unread,
Dec 18, 2008, 3:58:40 PM12/18/08
to vim...@googlegroups.com
> Hey I'm trying to map ^Z to save and then suspend.
>
> :map ^Z :w<CR>^Z
>
> I think I've got it right because I tried replacing the ^Z on the right side
> and it works perfectly. Problem is with anything I've put before ^Z it
> repeats infinity. Luckily this was just the w command at first, but was a
> little dangerous when I had to interrupt a save to get out of the save file
> infinite loop...

Use :noremap not :map so it doesn't map itself.

You can use <C-z> instead of ^Z, too:

:noremap <C-z> :w<CR><C-z>

Ben.

Charles Campbell

unread,
Dec 18, 2008, 4:05:58 PM12/18/08
to vim...@googlegroups.com
Derek Litz wrote:
> Hey I'm trying to map ^Z to save and then suspend.
>
> :map ^Z :w<CR>^Z
>
> I think I've got it right because I tried replacing the ^Z on the right side
> and it works perfectly. Problem is with anything I've put before ^Z it
> repeats infinity. Luckily this was just the w command at first, but was a
> little dangerous when I had to interrupt a save to get out of the save file
> infinite loop...
>
> Any ideas?
>
:help noremap

Regards,
Chip Campbell

Marc Weber

unread,
Dec 18, 2008, 4:40:00 PM12/18/08
to vim...@googlegroups.com
On Thu, Dec 18, 2008 at 12:51:07PM -0800, Derek Litz wrote:
>
>
> Hey I'm trying to map ^Z to save and then suspend.

Have you had a look at :h 'autowrite' ?
Maybe setting that option is enough?

Sincerly
Marc Weber

Derek Litz

unread,
Dec 18, 2008, 7:15:10 PM12/18/08
to vim...@googlegroups.com


Thanks! This would make sense as to why it was repeating... :)
--
View this message in context: http://www.nabble.com/Map-Suspend-Function-tp20987147p21083585.html

Tony Mechelynck

unread,
Dec 18, 2008, 9:07:27 PM12/18/08
to vim...@googlegroups.com
On 18/12/08 21:51, Derek Litz wrote:
>
> Hey I'm trying to map ^Z to save and then suspend.
>
> :map ^Z :w<CR>^Z
>
> I think I've got it right because I tried replacing the ^Z on the right side
> and it works perfectly. Problem is with anything I've put before ^Z it
> repeats infinity. Luckily this was just the w command at first, but was a
> little dangerous when I had to interrupt a save to get out of the save file
> infinite loop...
>
> Any ideas?

Possibility 1) Use :noremap instead of :map

Possibility 2) Use

:map <C-Z> :wall | suspend<CR>


Best regards,
Tony.
--
There is a theory which states that if ever anyone discovers exactly
what the Universe is for and why it is here, it will instantly
disappear and be replaced by something even more bizarre and
inexplicable. There is another theory which states that this has
already happened.
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

Reply all
Reply to author
Forward
0 new messages