Hi Christian: > Can you explain the problem in more detail? I don't have the old thread > around. Please be precise and explain exactly what you did, expect and > see.
It's good you asked :-) Made me poke around some more and fix my Duplicate function to read correctly (functionality was reasonably correct, but it's much clearer now). > I don't have the old thread around. FWIW Google Groups does have the full thread archive ( you can try the URL I have https://groups.google.com/forum/#!topic/vim_use/EukZDOaDACo ) Issue 1 (the original post) centered around how to add a range to a simple command. I received friendly pointers, but I was not able to get the correct response by looking at other plugins. I think this is in part due to a general preference for mappings as opposed to user commands in the vim community as a whole (whereas I'm a fan of user commands). The <line1> and <line2> parameters are the correct answer, but my reading of the docs was not sufficient for me to work this out. Not until going back to the docs, and reading down to the example case (well past the base description of -range) did I see the <line1> and <line2> automatic parameters. That's the crux of the real answer. By inspection of google results (and possibly some of the links to other plugins suggested) I worked out an incorrect, but functioning function (with issues). Bear with me, as this is fairly detailed. I was able to extract visual range by using the '< and '> markers. Oddly enough this works in my .vimrc, but it does not work in sample code I just wrote and sourced to test this. I also had an issue with the how the range command was specified (I chose -range=% which auto-populates line1 and line2, normally not a big deal, but in this case a non-ranged select reads line1=1 and line2=CURRENT_LINE). After investigation, I'm not at all clear why this worked. It does work in the function I created in my .vimrc. (Very) roughly function s:... vstart = line('">') .... endfunction command! -range=% call <SID>.... But trying to replicate this from a sourced file does not populate "< or ">. Due to the use of -range=% I received a spurioua value for line1 (i.e. "1" ) when there was no range selected. Thus the thanks at the top, as now the function is correct and working (as opposed to just "working"). -- -- 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 received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
