Loading ...
Sorry, an error occurred while loading the content.
 

RE: Few questions

Expand Messages
  • Roy Fulbright
    ... I have a few simple mappings that are specific to Perl IF statements, but they could easily be modified to any structure: 1-2. Open Perl IF statement and
    Message 1 of 7 , Apr 28, 2011
      > 3. How can I get vi to close out my (..), '..', {..}, and so on (this
      >     might become annoying but I'd like to try something like this anyway).

      I have a few simple mappings that are specific to Perl IF statements, but they could easily be modified to any structure:
       
      " 1-2. Open Perl IF statement and reposition cursor (normal and insert modes)
      noremap <silent><Leader>[ <ESC>aif () {<ESC><Left><Left>i
      inoremap <silent><Leader>[ <ESC>aif () {<ESC><Left><Left>i
      " 3. Close Perl IF statement and reposition cursor
      inoremap <silent><Leader>] <ESC>o
      " 4. Finish Perl IF statement and reposition cursor
      inoremap <silent><Leader>' <ESC>o}<CR>
       
      The first two maps (normal and insert modes) create the IF structure and reposition the cursor between the parens in insert mode to enter the condition(s).
      The third map escapes from insert mode and opens a new line in insert mode to enter the statement(s) under the IF.
      The fourth map escapes from insert mode, opens a new line with }, and issues a carriage return, which causes autoindent to align the closing brace.
       
      The characters after the leader were chosen for convenience and proximity to each other. '[' to open the IF, ']' to close the IF, and ' to finish the IF.
      Hope this helps.
       
      Roy
       

      --
      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
    Your message has been successfully submitted and would be delivered to recipients shortly.