Search code examples
vimautocompletesnipmate

move vim cursor after a function


I'm using both the supertab and snipmate plugins. Let's say I'm using snipmate to create an if statement structure. Once I'm done adding statements inside the if-statement, how can I quickly move the cursor after the if-statement. For example:

if [ $a = "b" ]; then
  bla;
fi

If my cursor is right on the semicolon and I'm in insert mode. What is the fewest number of actions I can take to move the cursor to the line after the 'fi'? If I press tab, supertab just open an autocomplete window.

Thanks


Solution

  • If you are using snipMate I'd suggest modifying the snippet for your file type. For instance the example you give looks to me to be something like a shell script snippet. In that case then I'd modify YOUR-VIM-CONFIGURATION-FOLDER/snippets/sh.snippets to us a definition like the following (adding an additional TAB variable at the end of the snippet):

    snippet if
      if [ ${1:condition} ]; then
        ${2:#statements}
      fi
      ${3}
    

    snipMate will then allow you to use the TAB and SHIFT-TAB keys to move back and forth between the condition, statements and end of the if block.