Saturday, October 1, 2011

Re: replace e flag works in command but fails if that command in key mapping

Using vim 7.2 on slackware 13.1
OK, I've traced the problem with the error flag not being suppressed. It is
caused because vim is still using an old version of .vimrc, not the current
version, i.e. it is using a version preceding my addition of the e flag to
those replace commands.

It does so because of another mapping in my .vimrc

" Type ;q to save all files and close out session
:map ;q :wa<CR>:mksession! ~/vim.ses<CR>:qa<CR>

According to :h mksession "When [!] is included an existing file is
overwritten." But that is not happening, and there is no warning message.
I closed out one of my open buffers, and ran that ;q command, then started
vim again. And the buffer that I had specifically closed out was back in
the open buffers list. When I separately rm vim.ses, and then run the ;q
command, it creates the vim.ses as expected.

So I decided to rm vim.ses in the mapping, changing it to

:map ;q :!rm ~/vim.ses<CR>:wa<CR>:mksession! ~/vim.ses<CR>:qa<CR>

but this caused a warning message to be displayed, requiring me to press
Enter to execute the rm, so I changed it again to

:map ;q :silent! rm ~/vim.ses<CR>:wa<CR>:mksession! ~/vim.ses<CR>:qa<CR>

which is certainly silent, but doesn't remove the file.


I seem to be going deeper and deeper into a morass with this seemingly
simple desire, that Vim should start in exactly the same state it had when I
last closed it. So how should I be doing this?

--
View this message in context: http://vim.1045645.n5.nabble.com/replace-e-flag-works-in-command-but-fails-if-that-command-in-key-mapping-tp4858038p4859875.html
Sent from the Vim - General mailing list archive at Nabble.com.

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

No comments: