IntelliJ Live模板中的自动大写变量 [英] Auto-Capitalize Variable in IntelliJ Live Templates

查看:121
本文介绍了IntelliJ Live模板中的自动大写变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(注意:这个问题与IntelliJ 14有关.较早或较新的版本可能没有此处提到的菜单.)

(Note: This question is in regards to IntelliJ 14. Older or newer versions might not have the menus mentioned here.)

我正在尝试设置一个实时模板,允许我在全部大写中键入一个常量.

I'm trying to set up a live template that allows me to type a constant in all caps.

因此,如果常规语法为 Titles.PAGETITLE ,那么我将创建一个实时模板,将 pt 扩展为 Titles.$ PAGETITLE $ ,结果应该是 Titles..在句点之后,将光标放在行上.

So, if the normal syntax is Titles.PAGETITLE, and I create a live template that expands pt into Titles.$PAGETITLE$, the result should be Titles. appearing on the line with my cursor placed after the period.

在这里,我希望将键入的任何内容插入所有大写字母,而无需使用Caps Lock或Shift键.我的小写输入应转换为大写输入.

It's here that I want whatever I type to be inserted in all capitalized letters, without using Caps Lock or Shift. My lowercase input should be converted to uppercase input.

我尝试在编辑模板变量对话框中使用 Expression 选项,并进行以下操作:

I've tried using the Expression option in the Edit Template Variables dialog with the following:

  • 预定义的大写(字符串)功能
  • 自定义编写的(String).toUpperCase()函数
  • 自定义编写的 Var.toUpperCase()函数
  • 我想不起来的其他几件事...
  • The pre-defined capitalize(String) function
  • A custom-written (String).toUpperCase() function
  • A custom-written Var.toUpperCase() function
  • A couple other things I can't recall off the top of my head...

我要完成的工作的一个更具体的示例实际上是一个自定义JSP标记,如下所示.

A more specific example of what I'm trying to accomplish is actually a custom JSP tag, as seen below.

<TAG:type property="<%=Titles.PAGETITLE%>" />

因此,如果我在一行上键入模板名称并进行扩展(以我的情况为'Tab'):

So if I type the template name on a line and expand it (with 'Tab', in my case):

tagtitle

然后应显示以下内容(光标位置的管道):

Then the following should appear (pipe for cursor position):

<TAG:type property="<%=Titles.|%>" />

当我键入 pagetitle 时,它应该像这样大写:

And as I type pagetitle, it should appear in caps like so:

<TAG:type property="<%=Titles.PAGETITLE%>" />

如何在已定义的实时模板中完成此操作?

How do I accomplish this from within the defined live template?

推荐答案

在IntelliJ IDEA中,在版本14或更高版本中均没有此类功能(截至撰写本文时,最新版本为2016.2).输入另一个变量后,可以使用实时模板中的表达式来基于另一个变量的值来计算模板中一个变量的值.键入时不能使用它们来更新变量的值.

There is no such feature in IntelliJ IDEA, either in version 14 or in a later version (2016.2 is the latest as of this writing). Expressions in live templates can be used to calculate the value of one variable in a template based on the value of another variable, after the other variable has been entered. They cannot be used to update the value of a variable as you type it.

这篇关于IntelliJ Live模板中的自动大写变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆