Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sublime text : how to fill paragraph?

In emacs, you can use meta-q "fill-paragraph" and in vim you can do gq - reformat paragraph (gggqG to fill the entire buffer)

Is there a similar key binding in sublime text?

Example:

Before fill-paragraph:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam

After fill-paragraph:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam
like image 258
user178047 Avatar asked Nov 12 '13 02:11

user178047


People also ask

How to create a file in Sublime Text Editor?

Step 1 − Use the option New File to create a file in Sublime Text editor. Step 2 − Once the new file is available, you can insert the code, similar to any other text editor, and save the file in your working repository.

What are the shortcut keys in Sublime Text?

Sublime Text works with all the standard Windows shortcuts: In addition to the arrow keys, home, end, page up, etc, there is: 1 Ctrl+Left / Ctrl+Right: Move by words 2 Ctrl+Home / Ctrl+End: Move to the beginning / end of the file 3 Ctrl+L: Expand selection to line More ...

How to append comments at the end of line in Sublime Text?

We can append comments at the end of line using the shortcut key Ctrl+Shift+L for Windows and Cmd+Shift+L for Mac operating system after selecting the code section where you actually need the comment. There are various types of code editing and shortcut keys used in Sublime Text editor −

What are the features of Sublime Text?

It includes wide features such as Syntax Highlight, Auto Indentation, File Type Recognition, Sidebar, Macros, Plug-in and Packages that make it easy for working with code base. This tutorial gives you a comprehensive coverage of concepts of Sublime Text and makes you comfortable to use it in your software development projects.


1 Answers

New Answer

OK, so I misunderstood your original question - as I now understand it, MetaQ-"fill-paragraph" rearranges paragraphs into lines of approximately-equal lengths. There isn't a function that matches this exactly in Sublime, but you can (re)wrap lines quite easily. You can set the ruler in your Preferences.sublime-settings file, using the "wrap_width" setting. Then, using AltQ on Windows/Linux, or AltQ on OS X, you can wrap selected text to that width (it defaults to 78 characters if "wrap_width" is set to 0). If you want to wrap to other (pre-selected) widths, go to Edit -> Wrap and there are a number of other options. To set a preferred width outside of what is in your preferences, open Preferences -> Key Bindings - User and add the following:

[
    // wrap lines at 25 characters
    { "keys": ["ctrl+alt+shift+w"], "command": "wrap_lines", "args": {"width": 25} }
]

You can obviously change the 25 to whatever value suits you. If you have no custom key bindings so far, copy and paste the entire contents above into the file. If you already have some key bindings, omit the outer square brackets, and remember to place a comma at the end of the line if it's not the final entry in the file. Good luck!

like image 168
MattDMo Avatar answered Oct 14 '22 18:10

MattDMo