![]() ![]() There's lots of places that multiple carets are helpful in IntelliJ IDEA, especially when you're working with lists. Let's say you want to add "Name" to these variables, but only to some of them: Windows hold down Alt and then Shift and click where you want the caret.macOS hold down Option and then Shift and click where you want the caret.You can then add the text even though the lines are not in a straight line:Ĭreate Multiple Carets at Any Point in Your CodeĪnd finally, what if you want multiple carets, but not in a stacked vertical line or at the end of each line? Again, the shortcut is similar: ![]() The caret will be placed at the end of each line. This time, instead of cloning the caret in a vertical line with the down arrow, hold down Option (macOS), or Alt (Windows/Linux) and use the mouse to place your caret to the right of the all the lines and then drag the mouse down. Public final String wolf = "Lives in Europe" Public final String stoat = "Lives in the United Kingdom" Let's say that you want to add something to the end of each of these strings, for example: public final String lion = "Lives in Africa" Note that for Windows the shortcut for this one is Alt, not Ctrl.Windows hold down Alt and drag the mouse down (or up).macOS hold down Option and drag the mouse down (or up).Place your cursor to the far right of the furthest line of code and: We can deal with that by using the mouse to drag the caret down, instead of the vertical arrow keys. How about dealing with a big list that you've pasted into your code? How can you inline everything? First let's make an array for our data, then we can use the same clone caret operation before wrapping it in braces and completing the statement:įinally, how about HTML tags? Again, it's the same process:Ĭreate Multiple Carets at the End of LinesĬontent at the start of your line is likely to be left-aligned, but that's not the case at the end of your line. You can also add final since you're here: You can then replace public with private just once, not three times. ![]() You can press Option (macOS), or Ctrl (Windows/Linux) twice, holding it down the second time you press it and then use arrow keys to create a tower of vertical carets. You could click each one and replace public with private but there's a faster way in IntelliJ IDEA. Let's say you have defined some variables at the start of your class, but retrospectively you realise that their scope should be private, and since we're defining them here, they should also be final: public String oak = "Oak"
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |