On Sun, Nov 20, 2011 at 5:10 PM, Tony Mechelynck [via VIM] <ml-node+s1045645n5009181...@n5.nabble.com> wrote:
> Yes, and why not use bar-separated commands? You _are_ running in > 'nocompatible' mode aren't you? The following (untested) assumes that > this mapping definition is part of a script (of your vimrc, maybe): Essentially I wrote scripts by trying each command individually in the buffer, then writing the script as a string that exactly mimics what I did with the individual commands, so normal-mode commands have no termination, ex mode commands are terminated by a carriage return. Now I understand that is not reliable. If the resulting script fits on a single line I put it directly in .vimrc, otherwise I make it a .vim script and map to that script in .vimrc. And yes, I use "set nocompatible" in .vimrc > > map p$ > \ :1d <Bar> > \ while @" != "" <Bar> > \ b # <Bar> > \ 1call search(@") <Bar> > \ s/^/$ / <Bar> > \ b # <Bar> > \ d <Bar> > \ endwhile<CR> > What I find particularly confusing is the lack of correspondence between command formats in scripts vs their counterparts in the buffer command line, as above. You are constrained to use :1d in both places, because 1d does something different in both places, but you use b# here to switch buffers, which requires :b# at the command line or you get a completely different result. Analogous to :1d, one would expect you to use :1/@" to go to line 1 and search for the content of the register, but you use the far lengthier '1call search(@")' instead. As far as I can determine the two forms work the same as far as / goes, but something must have prompted you to use search() instead? > See > :help 'nocompatible' > :help :bar > :help map_bar > :help line-continuation > :help :d > :help :call > :help search() > :help :s > :help :map-<buffer> > :help 'runtimepath' > :help :autocmd > :help FileType > > This would add a dollar and a space in front of the first line other > than the first in the alternate file which matches as a pattern any line > in the current file before the first empty line (or until end-of-file if > there is no empty line), and remove the matched lines (and the > terminating empty line, if any) from the current file. Repeated lines > cause repeated dollar-space insertion. If there is no match, add > dollar-space to the first line of the alternate file. If there are > several unmatched lines, add '$ ' that many times to the first line. If > a line in the current file starts with '$ ', the matching is done after > the changes for all preceding patterns have been made. > > I mention :map-<buffer> and what I listed after it because if you need > this mapping for only one filetype (or a small number of them), it > should be defined with <buffer>, either in an after-ftplugin, or > alternatively at the FileType event but still with <buffer>. > > > Best regards, > Tony. > -- > hundred-and-one symptoms of being an internet addict: > 222. You send more than 20 personal e-mails a day. > > -- > 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 > > > ________________________________ > If you reply to this email, your message will be added to the discussion > below: > http://vim.1045645.n5.nabble.com/In-script-always-search-from-start-of-buffer-tp5008841p5009181.html > To unsubscribe from In script always search from start of buffer, click > here. > NAML -- View this message in context: http://vim.1045645.n5.nabble.com/In-script-always-search-from-start-of-buffer-tp5008841p5010492.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