-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<idea-plugin version="2"> | ||
<id>com.your.company.unique.plugin.id</id> | ||
<name>Plugin display name here</name> | ||
<id>live_templates</id> | ||
<name>live_templates</name> | ||
<version>1.0</version> | ||
<vendor email="[email protected]" url="http://www.yourcompany.com">YourCompany</vendor> | ||
|
||
|
@@ -25,7 +25,9 @@ | |
--> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<!-- Add your extensions here --> | ||
<defaultLiveTemplatesProvider implementation="MarkdownTemplateProvider"/> | ||
<liveTemplateContext implementation="MarkdownContext"/> | ||
|
||
</extensions> | ||
|
||
<actions> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
import com.intellij.codeInsight.template.EverywhereContextType; | ||
import com.intellij.codeInsight.template.TemplateContextType; | ||
import com.intellij.psi.PsiFile; | ||
import org.jetbrains.annotations.NonNls; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Created by breandan on 1/11/2016. | ||
*/ | ||
public class MarkdownContext extends TemplateContextType { | ||
protected MarkdownContext() { | ||
super("MARKDOWN", "Markdown"); | ||
} | ||
|
||
@Override | ||
public boolean isInContext(@NotNull PsiFile file, int offset) { | ||
return file.getName().endsWith(".md"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Created by breandan on 1/11/2016. | ||
*/ | ||
public class MarkdownTemplateProvider implements DefaultLiveTemplatesProvider { | ||
@Override | ||
public String[] getDefaultLiveTemplateFiles() | ||
{ | ||
return new String[] {"liveTemplates/Markdown"}; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String[] getHiddenLiveTemplateFiles() { | ||
return new String[0]; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: Live Templates | ||
--- | ||
|
||
*Live templates* in IntelliJ IDEA are customizable rules that allow developers to abbreviate repetitive patterns of text in the editor. When a user types the designated abbreviation followed by a configurable *expansion key* (usually `Tab`), the IDE will transform the preceding input sequence to its full-length output, and update the cursor position. For example, consider a `for` loop. Typically, the end user would need to type `for(int i = 0; i < 10; i++) {<Enter><Tab><Enter><Enter>}<Up>`. This pattern may be shortened to `fori<Tab>` and the remaining contents will be expanded, leaving the following structure: | ||
|
||
``` | ||
for(int i = [|]; i < []; i++) { | ||
[] | ||
} | ||
``` | ||
|
||
As the user completes each section of the `for` loop and presses `Tab`, the cursor will advance to the next position in the editor. For more information about creating your own Custom Live Templates, you may refer to the [corresponding documentation](https://www.jetbrains.com/idea/help/creating-and-editing-live-templates.html). In this tutorial, we will illustrate how to add default Custom Live Templates to an IntelliJ Platform plugin, and assign valid contexts where these templates can take on added functionality based on the surrounding code and file type. We will discuss how to export existing live templates, and bundle them within a plugin to give plugin users added typing efficiency when using a custom language. | ||
|
||
* [1. Create a new Live Template](live_templates/template_support.md) |