Friday, 20 August 2010

IntelliJ Live Templates for Eclipse ...more

This is an update from an earlier post of mine so save me following two links & then having to edit the file.

To Import them into eclipse go to Window -> Preferences -> Java -> Editor -> Templates and import away.

<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<template autoinsert="true" context="java" deleted="false" description="iterate over array with temporary variable" enabled="true" name="itar">for (int ${index} = 0; ${index} &lt; ${array}.length; ${index}++) { ${array_type} ${array_element} = ${array}[${index}]; ${cursor} }</template>
<template autoinsert="true" context="java" deleted="false" description="iterate over collection" enabled="true" name="itco">for (Iterator ${iterator} = ${collection}.iterator(); ${iterator}.hasNext(); ) { ${type} ${element} = (${type}) ${iterator}.next(); ${cursor} }</template>
<template autoinsert="true" context="java" deleted="false" description="iterate with enumeration" enabled="true" name="iten">while (${enumeration}.hasMoreElements()) { ${type} ${element} = (${type}) ${enumeration}.nextElement(); ${cursor} }</template>
<template autoinsert="true" context="java" deleted="false" description="iterate over an array or Iterable" enabled="true" name="iter">for (${iterable_type} ${iterable_element} : ${iterable}) { ${cursor} }</template>
<template autoinsert="true" context="java" deleted="false" description="iterate with iterator" enabled="true" name="itit">while (${iterator}.hasNext()) { ${type} ${element} = (${type}) ${iterator}.next(); ${cursor} }</template>
<template autoinsert="true" context="java" deleted="false" description="iterate over list elements" enabled="true" name="itli">for (int ${i} = 0; ${i} &lt; ${list}.size(); i++) { ${type} ${element} = (${type}) ${list}.get(${i}); ${cursor} }</template>
<template autoinsert="true" context="java" deleted="false" description="public static final" enabled="true" name="psf">public static final ${} = ${cursor};</template>
<template autoinsert="true" context="java" deleted="false" description="public static final int" enabled="true" name="psfi">public static final int ${} = ${cursor};</template>
<template autoinsert="true" context="java" deleted="false" description="public static final String" enabled="true" name="psfs">public static final String ${} = ${cursor};</template>
<template autoinsert="true" context="java" deleted="false" description="main method" enabled="true" name="psvm">public static void main(String[] args) { ${cursor} }</template>
<template autoinsert="true" context="java" deleted="false" description="public void test" enabled="true" name="pvt">public void test${NAME}() throws Exception { ${cursor} }</template>
<template autoinsert="true" context="java" deleted="false" description="print to standard error" enabled="true" name="serr">System.err.println(${word_selection}${});${cursor}</template>
<template autoinsert="true" context="java" deleted="false" description="print to standard out" enabled="true" name="sout">System.out.println(${word_selection}${});${cursor}</template>
<template autoinsert="true" context="java" deleted="false" description="print method name to system out" enabled="true" name="soutm">System.out.println("${enclosing_type}.${enclosing_method}(${enclosing_method_arguments})"); ${cursor}</template>
<template autoinsert="true" context="java" deleted="false" description="print variable out to System out" enabled="true" name="soutv">System.out.println("${VALUE} = " + ${VALUE});</template>
<template autoinsert="true" context="java" deleted="false" description="public void test" enabled="true" name="test">public void test${NAME}() throws Exception { ${cursor} }</template>
</templates>