|
The e option in
:s/\<[a-z]/\u&/ge duly suppresses the error message if used as a command, but fails when used in the following key mapping in .vimrc " Type ;c to ConcatenateTitles and accumulate them in register z :map ;c :s/\<[a-z]/\u&/ge<CR>:s/[ ,.;:'"]//ge<CR>"Zyy producing "E486: Pattern not found: \<[a-z]" and failing to complete the command string Why different? |
|
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? |
|
Well, I think I finally have this figured out. If I'm using sessions,
any session includes its own .vimrc, being that .vimrc in effect when the session was first begun. Then changing the actual .vimrc file has no effect on the session, because it will never reload the actual .vimrc. So if I want to change a mapping in .vimrc, and have the benefit of that change in my session, I must make the new mapping explicitly in the current session, as well as in .vimrc. On Oct 1, 8:13 am, porphyry5 <[hidden email]> wrote: > 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-... > 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 |
|
On 02/10/11 16:04, porphyry5 wrote:
> Well, I think I finally have this figured out. If I'm using sessions, > any session includes its own .vimrc, being that .vimrc in effect when > the session was first begun. Then changing the actual .vimrc file has > no effect on the session, because it will never reload the > actual .vimrc. So if I want to change a mapping in .vimrc, and have > the benefit of that change in my session, I must make the new mapping > explicitly in the current session, as well as in .vimrc. On the contrary, starting Vim with -S will source your vimrc first; but then it will proceed with your session file, which may override anything your vimrc has set. You may use sessions without running :mksession -- a session file is just a Vim script sourced after your vimrc, usually to set up your windows and tabs and such. You can create one by hand, e.g. as cd ~ e file1.txt new file2.txt new /path/to/file3.txt lcd %:h tabnew /someotherpathto/file4.txt tabnew file5.txt tab help tabnext " wrap around to first tab wincmd w " wrap around to first window You can even name it ~/Session.vim, then "vim -S" or "gvim -S" will run it; and they will use all the settings of your vimrc too. Best regards, Tony. -- There's only one way to have a happy marriage and as soon as I learn what it is I'll get married again. -- Clint Eastwood -- 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're right, it does load .vimrc first, because *new* entries made to
that file show up in the session, but modified entries do not, because they are overwritten, and deleted entries still exist in the session, because the sessions file restores them. I really can't see the point of preserving these relic entries like this, surely one would always want to be using the most up to date .vimrc in its entirety. Instead what one gets is a mixture of the most recent .vimrc and the one in effect when the session was first created. That's confusing enough when one uses only one session, but if you have several of them for different projects, each using a different mix of .vimrc files? So I googled for solutions to this problem, and apparently these entries in vimrc, in the order given, will do the trick, though deleted entries will still live on in the session, but those present no problem. :autocmd! " Remove ALL autocommands for current group, ensures subsequent aus will only ever be included once au! BufWritePost ~/.vimrc source % " reload .vimrc each time the file is updated So now I'm going to kill my current session file and recreate it, and test this autocommand out. On Oct 2, 10:35 am, Tony Mechelynck <[hidden email]> wrote: > On 02/10/11 16:04, porphyry5 wrote: > > > Well, I think I finally have this figured out. If I'm using sessions, > > any session includes its own .vimrc, being that .vimrc in effect when > > the session was first begun. Then changing the actual .vimrc file has > > no effect on the session, because it will never reload the > > actual .vimrc. So if I want to change a mapping in .vimrc, and have > > the benefit of that change in my session, I must make the new mapping > > explicitly in the current session, as well as in .vimrc. > > On the contrary, starting Vim with -S will source your vimrc first; but > then it will proceed with your session file, which may override anything > your vimrc has set. > > You may use sessions without running :mksession -- a session file is > just a Vim script sourced after your vimrc, usually to set up your > windows and tabs and such. You can create one by hand, e.g. as > > cd ~ > e file1.txt > new file2.txt > new /path/to/file3.txt > lcd %:h > tabnew /someotherpathto/file4.txt > tabnew file5.txt > tab help > tabnext " wrap around to first tab > wincmd w " wrap around to first window > > You can even name it ~/Session.vim, then "vim -S" or "gvim -S" will run > it; and they will use all the settings of your vimrc too. > > Best regards, > Tony. > -- > There's only one way to have a happy marriage and as soon as I learn > what it is I'll get married again. > -- Clint Eastwood -- 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 |
| Powered by Nabble | Edit this page |
