46
votes
Accepted
The old "how to fold XML" question
I found this SO post: https://stackoverflow.com/questions/944614/emacs-does-hideshow-work-with-xml-mode-sgml-mode
(require 'hideshow)
(require 'sgml-mode)
(require 'nxml-mode)
(add-to-list 'hs-...
35
votes
Accepted
How to prettify/format an XML buffer?
Does the functionality already exist to reformat this buffer to be somewhat user-readable?
Of course, and you have plenty of options. I'd probably feed it to an external program using:
C-x h C-u M-| ...
30
votes
How to prettify/format an XML buffer?
The built-in sgml-mode has a command to do this: sgml-pretty-print. If you're in nxml-mode it looks like you need switch to sgml-mode first. You could write a command to temporarily switch to sgml-...
13
votes
The old "how to fold XML" question
web-mode has element folding built in and bound to C-c C-f. But you will lose some of the features of using nxml-mode obviously.
7
votes
How to prettify/format an XML buffer?
write this into your ~/.emacs.d/init.el:
(require 'sgml-mode)
(defun ninrod/reformat-xml ()
(interactive)
(save-excursion
(sgml-pretty-print (point-min) (point-max))
(indent-region (...
6
votes
How to prettify/format an XML buffer?
Mark your xml and do:
M-x sgml-pretty-print
Or just run the command without a marked region to prettify the whole buffer.
5
votes
Accepted
How pretty format XML in Windows?
Try the command sgml-pretty-print from sgml-mode. This operates on the region, so you could mark the buffer first:
C-x h
M-x sgml-pretty-print
Or maybe define a command :
(defun my-xml-pretty-print ...
4
votes
Accepted
How to show XPath for current location in an XML hierarchy in the modeline?
Install nxml-mode and which-function-mode. Take the nxml-where function from here and add it to your .emacs file followed by:
(defun xml-find-file-hook ()
(when (derived-mode-p 'nxml-mode)
(...
3
votes
Multiple modes for one file
Two options I'm aware of:
mmm-mode is a minor mode for Emacs that allows Multiple Major Modes
to coexist in one buffer. It is well-suited to editing:
Preprocessed code, such as server-side Ruby, ...
3
votes
How do I use Emacs as a feedly.com client?
Did you test elfeed? Is not a client for feedly.com, but you can read your RSS feeds within Emacs anyway
3
votes
Accepted
How do I use Emacs as a feedly.com client?
The answer is that you can't use Emacs as a Feedly client, or at least not without regenerating a developer key every three months. I received the same information as the folks at Feednix.
There are ...
3
votes
Accepted
Keybinding/Function to Close Xml Tag
You can close an XML block in nXML-mode via
C-c /
To find such functions, have a look at the mode's description, accessible via C-h m when in nXML-mode. It says
C-c / finishes the current element ...
3
votes
How to prettify/format an XML buffer?
In nxml-mode, C-x H will mark the whole buffer and TAB will indent the selection.
3
votes
One key shortcut to jump two-ways between matching opening/closing tags in nxml mode?
If you use evil-mode, you can install https://github.com/redguardtoo/evil-matchit and press %
If you prefer original Emacs,
(autoload 'sgml-skip-tag-backward "sgml-mode" nil t)
(autoload 'sgml-skip-...
3
votes
Open SVG files in XML mode
You'll probably like to either disable auto-image-file-mode or tweak image-file-name-extensions.
BTW, if Emacs crashes or hangs for a particular SVG file, I suggest you M-x report-emacs-bug about it. ...
2
votes
Accepted
Moving around within xml documents?
See nxml-mode, option nxml-sexp-element-flag, and movement commands such as nxml-forward-balanced-item, nxml-forward-element, and nxml-up-element.
If you use library Icicles then you can use Icicles ...
2
votes
Accepted
Insert json or XML blocks in org mode
Org babel "Supported languages" are languages that you can evaluate/execute directly from an orgmode code block. I don't think JSON and XML are executable languages anywhere, so you don't ...
1
vote
Disable flycheck in XML files
You can add the xml checkers to flycheck-disabled-checkers. For instance, if you are using use-package in your init file:
(use-package flycheck
:ensure t
:config (global-flycheck-mode)
(with-...
1
vote
Android manifest - find launch activity name programmatically
You can use xml.el to handle XML data. The following function should provide you with the class names you are looking for:
(require 'xml)
(require 'seq)
(defun activity-from-manifest (manifest)
(...
1
vote
Open SVG files in XML mode
I have a solution that does 2 things:
Attempt to open any XML file in nXML mode, and this obviously needs to include SVG files.
If such a file is an SVG file, then define C-c C-c to image-mode.
For ...
1
vote
Adding XUL file syntax highlighting support?
I found the solution:
(setq auto-mode-alist
(append '((".*\\.xul\\'" . nxml-mode))
auto-mode-alist))
1
vote
Accepted
How do I edit an XML file in Emacs with tag autocompletion from a known XSD schema?
Turns out the hardest part has to be done outside Emacs.
Install auto-complete and auto-complete-nxml from MELPA (easy).
Note: don't use genrnc from MELPA 'cause it does not fit the bill...
Ensure ...
1
vote
how to fold xml file (or specifically build.xml)
You need to add this hook:
(add-hook 'nxml-mode-hook 'hs-minor-mode)
After that put this in your init.el file or somewhere it'll be loaded.
(define-key nxml-mode-map (kbd "C-c h") 'hs-toggle-hiding)...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
xml × 27nxml × 9
org-mode × 4
motion × 2
formatting × 2
xml-schema × 2
key-bindings × 1
org-export × 1
major-mode × 1
terminal-emacs × 1
mode-line × 1
flycheck × 1
images × 1
string × 1
code-folding × 1
navigation × 1
repl × 1
json × 1
sql × 1
outline × 1
pretty-print × 1
frozen-emacs × 1
android × 1
web × 1
consult × 1