On Apr 20, 4:40 pm, stosss <[email protected]> wrote: > > map #6 i<i><Esc>ea</i><Esc> " wraps one word > > map #7 i<b><Esc>ea</b><Esc> " wraps one word >
You want to be able to wrap arbitrary areas, you suggested using a visual selection to do so. If you want to stick with your prior approach (jump to the beginning, insert text, jump to the end, insert text), you can do so using marks. In general, a mark is a place in a buffer which you can jump to with a single command, namely the ' or ` operator, followed by the name of the mark. You can manually set marks a-z and some others using, for example, ma to set the location of the 'a' mark. You can then jump to that same line with 'a or to the same line AND column using `a. This is all interesting, but more interesting (to you) may be that whenever you create a visual selection, the < and > marks are automatically set to the beginning and end of the visual selection. So, you can create a mapping to jump to the beginning of the visual selection (`<), insert text, jump to the end (`>), and insert more text. See the following :help sections: bookmark mark-motions (a really big section, read it all, but pay special attention to those things mentioned above) This or Gary's solution should work fine. HOWEVER, I would instead suggest the use of a plugin that has done all this dirty work for you, called surround.vim. Look it up on www.vim.org. This plugin is one of a select few that I actually use; in general I like to script things for myself or use built-in commands. If you do choose to use surround.vim, it would be good to read up on :help text-objects. Actually, that is good reading regardless of whether you use surround, I cannot recommend enough that you read it. But, it does not directly apply to your problem without surround (though you could use it to select text visually). -- 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
