views:

129

answers:

4

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

+2  A: 

Non sure about the plugins (I don't use them, but in regular vim):

<Esc>
/fi$
o

The $ sign might be superfluous most of the time.

Tomislav Nakic-Alfirevic
A: 

Just press C-o o

Tassos
A: 

I would press Esc o to start insert mode on the next line. But perhaps you could reconfigure snipmate so that you can press some other key instead of tab to finish the snippet?

If you haven't mapped it, the down arrow key should also move the cursor to the next line.

too much php
+2  A: 

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.

dsummersl