On Tue, Apr 20, 2010 at 6:44 PM, stosss <[email protected]> wrote: > On Tue, Apr 20, 2010 at 6:26 PM, Gary Johnson <[email protected]> wrote: >> On 2010-04-20, stosss wrote: >>> On Tue, Apr 20, 2010 at 4:31 PM, Gary Johnson <[email protected]> wrote: >>> > On 2010-04-20, stosss wrote: >>> >> On Tue, Apr 20, 2010 at 1:48 PM, Brett Stahlman wrote: >>> >> > On Apr 19, 2:00 am, stosss <[email protected]> wrote: >>> >> >> Again I have read :help visual-mode and :help map as in my other post >>> >> >> about visual-mode I can't figure out how to make it work. >>> >> >> >>> >> >> Will some one enlighten me? >>> >> > >>> >> > Perhaps if you gave an example of what you were trying to >>> >> > accomplish... >>> >> > >>> >> >>> >> As I have declared in the few posts that I have sent to this list, I >>> >> am still knew and learning. Maybe my approach is wrong or not as good >>> >> as another approach. >>> >> >>> >> I figured out how to set up a map to wrap a word or an entire line in >>> >> an HTML tag. Sometimes I want to wrap more than one word but less then >>> >> the whole line. >>> >> >>> >> Although I am reading help I don't always know all the pieces needed >>> >> to accomplish my task. >>> > >>> > As Brett tried to explain, no one can help you if they don't know >>> > the "it" you are trying to make work. If something you are doing is >>> > not working as you expect it to, then show here _exactly_ what you >>> > are doing. That is, show _exactly_ the commands you are executing >>> > or the sequence of keys you are typing. Include the text you are >>> > attempting to edit. Then show or explain _exactly_ the results you >>> > are getting and explain the results you expected to get. >>> > >>> > This may help. >>> > >>> > http://catb.org/~esr/faqs/smart-questions.html >>> > >>> > Even if you are looking for broader knowledge than just the answer >>> > to a particular problem, a particular problem can be the starting >>> > place. It will give people here a better idea of what you do and >>> > do not know and will help them suggest specific areas of the Vim >>> > documentation that you might benefit from reading. >>> >>> Working with *any* HTML tag, here are some examples: <p> <b> <i> <h2> <br >>> /> <a> >>> >>> I have several maps created. The ones I have created all work as expected. >>> >>> Take the <i> and <b> tags. I am able to use my maps to wrap one word >>> or an entire line. >>> >>> What I don't know how to do, or even where to look, is make a map to >>> wrap more than one word but less then the entire line with an HTML >>> tag. I have created examples below. >>> >>> All the maps that I have created either work with one of the <F[2-9]> >>> or have \ in the first keystroke of the map command. >>> >>> examples: >>> >>> in my ~/.vimrc I have: >>> >>> map #6 i<i><Esc>ea</i><Esc> " wraps one word >>> >>> map #7 i<b><Esc>ea</b><Esc> " wraps one word >>> >>> map \i8 0i<i><Esc>$a</i><Esc>0 " moves cursor to ^ wraps everything >>> from ^ to $ and then moves cursor back to ^ >>> >>> >>> One line of text with a lot of filler to <i>show</i> map results of >>> the first map above. >>> >>> Second line of text with a lot of filler to <b>show</b> map results of >>> the second map above. >>> >>> <i>Third line of text with a lot of filler to show map results of the >>> third map above.</i> >>> >>> Forth <i>line of text</i> with <b>a lot of filler</b> to illustrate >>> desired results. >>> >>> I don't know what to read to learn how to create a map that I can >>> execute and then tell it how many words to wrap with the HTML tag. >> >> Someone posted a number of good solutions to this problem fairly >> recently, but I can't seem to find that thread at the moment. As I >> recall, one of the solutions used the substitute command s within a >> visually-selected region to replace the selected text with that same >> text preceded and followed by the desired tags. I'm not sure how >> good a solution the following is, but it seems to work. >> >> :vnoremap #3 ygvs<i><C-R>"</i><Esc> >> >> That yanks the visually-selected text into the default register (y), >> re-selects the region (gv), substitutes the text in that region (s) >> with the initial tag (<i>) followed by insertion of the previously >> yanked text from the default register (<C-R>") followed by the end >> tag (</i>) and ends the substitution (<Esc>). >> >> Most of the information on visual-mode is in >> >> :help visual.txt >> >> For a more tutorial approach, you could start with >> >> :help toc >> >> and search for "visual". That will show you the sections >> >> :help 04.4 >> :help 10.5 >> :help 26.1 >> >> The commands I used above are explained in >> >> :help visual-operators >> :help gv >> :help i_CTRL-R >> :help mapmode-v >> :help 40.1 >> >> Getting back to your statement that you didn't know how to specify a >> certain number of words to wrap, once you enter visual mode by >> typing 'v', you can continue to move the cursor using most of the >> usual normal-mode commands. For example, to select three words to >> wrap, you could move the cursor to the first word, then type >> >> v3e >> >> You can also move the cursor to the opposite end of the >> visually-selected region by typing 'o'. So for example, after >> selecting those three words you might discover that you wanted the >> preceding word as well. Then you would just type >> >> ob > > Thank you, this should get me going. I will read all those help > sections and play around with this to see how to actually be able to > use it.
I have been using this new information for about an hour. This is totally awesome! The more I learn how to use this editor the more I see the power of it. I like it! -- If we can but prevent the government from wasting the labours of the people, under the pretence of taking care of them, they must become happy. - Thomas Jefferson -- 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 Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en
