Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a command for inserting a line of characters in Sublime Text 2?

Tags:

sublimetext

I tend to use lines of hashes and dashes for formatting and breaking up code files (e.g., CSS files):

/* -------------------------------------------------------------------
 * Layout Styles
 * -----------------------------------------------------------------*/

In vim I would use the command 80a-<ESC> which would insert 80 - characters from the location after the cursor.

I've poked around in the Sublime documentation, but haven't come across a good way of replicating the above vim command in subl. Vintage mode does not include support for this command sequence.

Is there a corresponding command that does something similar in Sublime or would a static snippet be the simplest solution?

like image 882
krohrbaugh Avatar asked Mar 28 '12 15:03

krohrbaugh


People also ask

How do I add a new line in Sublime Text?

To insert a new line below the current line in your code, hit Cmd–Return (Mac) or Ctrl–Enter(Windows). You can also insert a new line above the current line by using Cmd–Shift–Return(Mac) or Ctrl–Shift–Enter (Windows).

How do I type multiple lines in Sublime Text?

While you can place multiple text cursors in Sublime Text with Cmd–Click (Mac) or Ctrl–Click (Windows), here's another technique that comes in handy. Hold Ctrl–Shift (Mac) or Ctrl–Alt (Windows) and hit Up or Down Arrow to place an additional text cursor above or below the current cursor.

How do you go to a specific line in Sublime Text?

In Sublime Text, you can quickly jump to any line in the code. Hit Ctrl–G (Mac and Windows). Type in a line number and hit Return/Enter to go to that line.


1 Answers

I don't think there is any repeat character possibility. To do this with any character I think would require a plugin, but the basic functionality of inserting a big comment block can easily be achieved with a snippet:

Go to New Snippet through the menus and add this code:

<snippet>
    <content>
        <![CDATA[
/* -------------------------------------------------------------------
 * $0
 * -----------------------------------------------------------------*/
        ]]>
    </content>
<tabTrigger>comment</tabTrigger>
</snippet>

then save the snippet in your Packages\User folder, as something.sublime-snippet. Should work straight away, you just have to type comment (or whatever you change it to..) then hit tab, then actually write your comment title.

like image 171
fraxel Avatar answered Oct 05 '22 03:10

fraxel