Questions tagged [formatting]

is for text formatting and manipulating text attributes. Emacs formatting facilities include adding, changing, and describing fonts, faces, and colors. The complexity of the formatting functions depends on the major mode and customizations. Use this tag for questions about formatting time strings and mode-line also.

Filter by
Sorted by
Tagged with
34 votes
3 answers
12k views

Command that formats (prettifies) Elisp code

Let's say I have a function that looks like the following (as is often the case when printing elisp output). (defun my-example-function () (let ((a (do-something)) (b (do-something))) (setq someone ...
  • 22.5k
31 votes
6 answers
20k views

How to prettify/format an XML buffer?

I have a file with xml all on one line. Does the functionality already exist to reformat this buffer to be somewhat user-readable?
  • 3,507
21 votes
5 answers
5k views

Can I format cells in an org-mode table differently depending on a formula?

I have a column in an org-mode table with numbers in each cell. I'd like to change the background color of the cell to red if the number is below 1 or above 2. How can I do that?
  • 1,795
18 votes
4 answers
3k views

Org mode - Parsing rich HTML directly when pasting?

Currently, for notetaking tools like Evernote and Quiver, I can directly copy HTML content from my favorite browser and then paste them into the app, with all the formatting + link preserved. However ...
  • 2,405
16 votes
4 answers
7k views

Automatically formatting SQL code

There are some general well-known coding standards and styles for SQL (e.g. capitalizing reserved words, placing main keywords in different lines, etc.). Does Emacs come with any modes for this, or ...
15 votes
1 answer
2k views

Make org-mode markup symbols invisible?

In Emacs, one can use asterisks * to achieve bold font, for example, *bold*. My question is can I make the asterisks invisible? i.e. bold instead of *bold*. Same question for strike through, italics, ...
  • 415
13 votes
2 answers
7k views

How prettify (newlines and indentation) an optimized HTML/JS file?

For example, I have the following bunch of characters (HTML): http://pastebin.com/pwTPp8wd I thought everyone stumbled it upon a processed file, especially when someone would speed up the processing ...
  • 3,765
13 votes
5 answers
5k views

How to auto-format the source code block in org-mode

When I'm using org-mode to take notes about a book, sometimes I'll copy/paste some code snippets into the note file. After pasting it, I'll 1. `C-c '` to call `org-edit-special` 2. `C-x h` to mark ...
  • 2,559
12 votes
1 answer
2k views

How to keep indented under plain list items in org-mode

While regular paragraphs are happily indented under plain list items (using [SPACE] bar to indent the first line takes the rest along with) I have noticed that code blocks do not like to cooperate. Is ...
  • 1,775
11 votes
1 answer
3k views

Why does *compilation* buffer show control characters?

I'm using the *compilation* buffer to build a C++ application on Centos 5 and Centos 6. The buffer shows the build and includes references to files that are part of the build. However, I'm getting ...
  • 353
10 votes
3 answers
2k views

Org-mode export: indent first line of each paragraph, "literary" style

Is there a switch on org-mode I can use on export to ODT (or other format) to format my source file of This is a paragraph this is a paragraph this is a paragraph this is a paragraph this is a ...
9 votes
4 answers
4k views

Automatically formatting brackets

I'm trying to create a function that places/aligns/indents curly brackets according to Allman-style formatting (for coding in C). Generally speaking, I am fan of Smartparens' interface available to ...
  • 1,078
9 votes
3 answers
2k views

Print message in echo area with no "quotes"?

Q: how do I print a message in the echo area without surrounding quotes? Here's a simple command: (defun test-fn () (interactive) (message "Test message")) When I call it as an interactive ...
  • 31.3k
8 votes
1 answer
349 views

Formatting of usepackage commands in LaTeX document

I'm trying to use AUCTeX edit LaTeX files. The beginning of the document I just wanted to edit looks like this: It's not neatly organized, inconsistent in many ways, and I should probably change it ...
  • 855
7 votes
1 answer
156 views

Library that converts a Python output string to an Elisp data structure?

Say that I evaluate the following Python code: import inspect import scipy.ndimage.filters list (inspect.getargspec (scipy.ndimage.filters.gaussian_filter1d)) # => [['input', 'sigma', 'axis', '...
  • 13.6k
7 votes
1 answer
3k views

"Format Code" like in Eclipse

In Eclipse, I can hit CTRL + SHIFT + F which not only corrects the indentation but also whitespace (for example: c=a +b ; is corrected to c = a + b;) and the line length. I am looking for a similar ...
6 votes
1 answer
555 views

Editing Fortran90 in a fixed format mode

I am currently writing a user-script for a simulation software, and the program requires the use of Fortran90 syntax in 132-columns fixed format. Emacs has two Fortran modes that I know of, fortran-...
  • 752
5 votes
2 answers
2k views

Incrementing characters in Emacs, next to numbers?

You can place a pointer on a number, like 1, and increment it to 2. There are many alternatives on this. See also the Emacs Wiki: https://www.emacswiki.org/emacs/IncrementNumber 7 alternatives to ...
  • 3,765
5 votes
1 answer
920 views

Make emacs format Java more consistently

When I open Java files originally created and edited in Emacs, the indentation shows up correctly, as in the image below: However, when I open the same file in Sublime Text, or any other editor ...
  • 53
5 votes
1 answer
996 views

How to export org files to plain text files as it looks like in clean view?

I want to print org files or share them with in emails. Clean view looks good for these purposes. Is it possible to export org files so that the output text file looks exactly like clean view (of ...
  • 425
5 votes
1 answer
1k views

How to break long lines automatically?

I have searched the googlewebs, but I have been unable to find an emacs package that will automatically break long lines in a (Python) language conforming way. For example: def ...
4 votes
2 answers
215 views

Disabling quote conversion in docstrings

(defun foo () "`bar'") The ASCII quotes in this docstring are displayed as typographical quotes by describe-function. Is it possible to have them displayed in their original form?
  • 2,984
4 votes
2 answers
480 views

How can I use par as my paragraph formatter

I'm coming from vim, which has a gq operator that acts much like emacs' fill-paragraph function (M-q). There's a 'formatprg' setting that allows you to point gq at an external program for its ...
  • 1,878
4 votes
1 answer
1k views

How to run a custom formatting tool on save?

While there are packages that format on save, I'd like to be able to run a custom command that auto-formats a file on save. Upon saving it runs an external process that: Takes the buffer as stdin. ...
  • 7,441
4 votes
1 answer
580 views

Is there a way to recognize `-- vim: et:sw=4:ts=8:sts=4:tw=80` in emacs?

I'm working on a project with all source files appended with this vim formating rule -- vim: et:sw=4:ts=8:sts=4:tw=80. Is there a way to make Emacs setup the correct indentation for me automatically? ...
  • 416
4 votes
1 answer
546 views

Is there a command/package to pretty print based on parentheses?

I'm dealing with large files of output from Haskell code, most of which is debug info of stuff generating using Haskell's show. The important thing about that is that it's a large file of things, ...
  • 183
4 votes
1 answer
129 views

Format fails to copy text properties from the format-string for adjacent %-sequences

Take a look at this example: (format (concat "%s" (propertize "%s" 'face 'error)) "foo" "bar") "foobar" (format (concat "%s " (propertize "%s" 'face 'error)) "foo" "bar") #("foo bar" 4 7 (face error)...
  • 222
4 votes
0 answers
546 views

How to display and format leading spaces (spaces at the beginning of a line) with whitespace-mode? [closed]

I want to see all spaces at the beginning of a line as dots. Also tabs and line breaks. So I've set my init.el file as the following: (setq-default indent-tabs-mode nil) (setq whitespace-style '(...
  • 151
4 votes
0 answers
141 views

Add spaces between braces and content

I would like to automatically add spaces between braces and content when using emacs, for example: std::vector<std::string> values{"content", "moreContent", "andMoreContent"}; becomes std::...
  • 41
3 votes
3 answers
1k views

Insert left and right double quotation marks instead of ordinary quotation mark

For a given document (buffer), I would like use left double quotation mark “ (U+201C) and right double quotation mark ” (U+201D) instead of the ordinary double quote " (U+0022). I want to surround ...
3 votes
2 answers
262 views

Email Code Snippets through Emacs (with Mutt)

Frequently, I find myself having to send code snippets to teammates, etc. Therefore, I decided to write the following elisp to simplify the process. I am using mutt as the email client, but the only ...
  • 288
3 votes
1 answer
448 views

How can I easily word wrap long text files that include programming code

In emacs, the command "escape-q" word wraps a paragraph. However a lot of text I copy from the internet has paragraphs that each consist of several sentences, but are not separated by blank lines. ...
3 votes
0 answers
154 views

Org-mode: custom syntax for smallcaps, like *bold* and /italic/

I use org-mode a lot to export PDFs through LaTeX. How can I define a custom syntax for org-mode to mark small caps—so, for example, ^this^ gets translated to \textsc{this}, the way *this* gets ...
3 votes
0 answers
109 views

how can i configure sgml-mode to format open and close tags on same line?

I set up my emacs to use sgml-mode so that I can format xml with M-x reformat-xml, but it puts the closing tags on the line below, rather than on the same line. instead of this: <mytag>stuff &...
  • 241
3 votes
0 answers
314 views

Like JavaScript prettier but for Elisp

(N00b question.) Is there command/package/snippet to format elisp code (like in my init file) in a standard(-ish) way, like what Prettier does for JavaScript? I'm not only concerned about ...
2 votes
1 answer
167 views

Why does M-x underline-region doesn't work?

I don't know if I'm using the command correctly or not. I select the region to be underlined and then pass the command M-x underline-region and it doesn't work. For example if the text is SAMPLE ...
  • 1,360
2 votes
1 answer
329 views

How to set project-specific javscript indentation using js2-mode

I have several Javascript projects, where some projects use 2 spaces for indentation and other projects use 4 spaces for indentation. Is there a project-specific way to set the indentation? I am able ...
  • 2,340
2 votes
1 answer
1k views

How to format code comprehensively, not just indent region, but apply correct coding style

I switched from Sublime Text a little over a month ago and I prefer emacs, but something that I haven't been able to find are external packages that do more than just give you more than correct ...
  • 693
2 votes
1 answer
162 views

How do I stop tab from being electric in Text mode?

When editing a plain-text document in Text mode when I press tab emacs inserts spaces until the cursor appears directly beneath the beginning of a word it finds in the line above. I don't want it to ...
2 votes
1 answer
1k views

Automatically reformat org buffers

I make intensive use of org-mode and it boosts my productivity significantly. But I'm missing the possibility to adjust the space between headings automatically. On the one hand I want to define the ...
  • 1,659
2 votes
1 answer
658 views

How can I hide formatting marks after the formatting they define has been applied in markdown mode?

I am using markdown mode with the modifications suggested in the excellent answer I received to a previous question. My aim is to have basic rendering capabilities within emacs itself so I can ...
  • 745
2 votes
1 answer
3k views

Org-mode font size changes with formatting

In Windows I've set my default font height to 120 with: (set-face-attribute 'default nil :height 120) This seems to not take effect in org-mode, however, when specially formatting is applied. For ...
  • 3,849
2 votes
1 answer
131 views

Getting rid of plain text timestamp entry in agenda export

I am trying to create a weekly agenda that I can print out and use without having to be at the computer To best explain my problem I will use some screenshots This is the normal org file that I will ...
2 votes
1 answer
291 views

yaml-mode empties whitespace lines

Our project has a large yaml file edited by multiple developers in multiple environments. When I edit the file in emacs, yaml-mode (I assume?) will trim any whitespace lines: Value: ...
  • 395
2 votes
1 answer
29 views

In M-x Info (C-h i), tables are not correctly aligned

Problem When trying to browse documentation in M-x info ≡ C-h i, the table of contents is not correctly aligned. One would expect * Introduction This is the etc etc etc etc etc . * Details ...
  • 1,501
2 votes
2 answers
949 views

What prevents emacs from indenting and how can I force it to?

In certain modes, such as Python I have noticed that Emacs will not indent how I want it it to. It is getting "smart". For instance, in this block of code: def vec_select(veclist, k): ...
  • 1,274
2 votes
1 answer
571 views

Automatically indent ONLY logical lines in Org-mode

I want this: ** This is a heading This is a logical line. But, because I have visual-line-mode on, lines will wrap at the edge, as is just and godly. But, such elegant formatting as you see here ...
2 votes
0 answers
634 views

Non-breaking space in Org-mode

In LaTeX one can use ~ to produce a non-breaking space. Is there an analogue in org-mode?
  • 865
2 votes
0 answers
53 views

Quoting selected text using email conventions?

Is there any existing elisp function which will quote any selected text using email quoting conventions? For example, suppose the following text appears in a buffer ... This is some text that I want ...
  • 552
2 votes
0 answers
542 views

Source code pretty-printer / beautifier / formatter for minified HTML/CSS/JS using only code I can trust?

I am reverse engineering foreign web site and have a lot of minified code for CSS/HTML/JS. What package or tricks allow to beautify code? I am usually replace \([{}]\) to \1\n and C-x h C-M-\ (...
  • 3,180