Rory Campbell-Lange wrote: 
  
  > I'd like to:
  > 
  >     1. Select some text
  >     2. Hit a key sequence such as ;t
  >     3. Be prompted for a tag (I'll input something like 'b' or 'h1')
  >     4. The text selection will be wrapped in -- say -- 
  >        <b>text selection</b>
  > 
  > What doesn't work so far: 

  I assume step 1 is a visual selection.  

  What you might not know:

  Whenever something is selected in visual mode, vim automatically
  marks the two end points of the selection with the marks < and >.
  You can jump to these locations by normal mode commands `< and `>.
   
  > map ;t <ESC>:call Tag_Maker()<CR>
  > function! Tag_Maker()
  >     let l:tagger = input("tag? ")
  >     normal  @zd

  Don't know why you have the preceding;  what is needed is a jump
  to the "start" of the visual selection with

        normal `<

  >     execute "normal i<" . l:tagger . ">"
  >     normal @zp

  Don't know why you have the preceding;  what is needed is a jump
  to the "end" of the visual selection with

        normal `>

  >     execute "normal a</" . l:tagger . ">"
  > endfunction
  > 
  > Basically I don't know what I'm doing with the execute and
  > normal commands. I'm sorry to say that a read of usr_41 hasn't
  > helped much!
   
  It helps to first do the operations manually -- the code is then
  just a record of what was done manually.

  --Suresh

Reply via email to