On Wed, Apr 21, 2010 at 12:42 PM, Ben Fritz <[email protected]> wrote: > > > 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)
I had actually read about these marks but could not figure out how to use them. I will revisit that part of help now that I have some understanding of this visual-mode stuff thanks to the help in this thread. > This or Gary's solution should work fine. HOWEVER, I would instead What Gary showed me was awesome. > 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. I have the surround.vim and could figure it out. I think I have it set up right. I will revisit that as well. > 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). A paragraph in the 2nd chapter of the book Learning the vi and Vim Editors 7th Edition says, "Later chapters will show you how to expand your skills to perform faster and more powerful edits. One of the biggest advantages for an adept user of vi is that there are so many options to choose from. (One of the biggest disadvantages for a newcomer to vi is that there are so many different editor commands.)" The first sentence is true with respect to the first part of the book and the last part of the book, but it doesn't even come close to revealing the power of Vim. I have learned a lot more since reading the help sections in Vim. The second and third sentences are totally true. I am still trying to decide if I reflect the third sentence or the second sentence. :-) -- 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
