Hot answers tagged

50

Assuming that the variable python-indent is 4: M-x python-shift-right (C-c >) M-x python-shift-left (C-c <)


13

You can use the Edit / Line / Reindent from the edit menu. Or you could try adding this to your keybindings - Default file from preferences. { "keys": ["f12"], "command": "reindent"} Add a comma at the end of the code if you use the Default file instead of the users. Don't forget to select what you want indented. You could potentially just use Visual ...


11

indent-rigidly takes a prefix argument indicating how much to indent by, so C-u 42 C-x TAB indents by 42 columns, and since the default prefix argument is 4, C-u C-x TAB indents by 4 columns. If you want to select the region again, do C-x C-x afterwards.


10

It looks like Adobe Brackets has an extension called Beautify which can be found at https://brackets-registry.aboutweb.com/ and their GitHub location is https://github.com/drewhamlett/brackets-beautify


9

An answer to this question on Stack Overflow indicates that 'cc' will replace the contents of the current line and enter insert mode at the correct indentation


6

It's not part of the language definitions. TextMate simply remembers the setting you last selected for documents of a given language setting. This setting is at the bottom of each window: The preferences are stored in ~/Library/Preferences/com.macromates.textmate.plist, in the arrays OakTextViewScopedTabSize (tab size) and OakTextViewScopedSoftTabs ...


5

I guess this and this could be an answer to your question. Installation is easy. Invoke git clone git@github.com:antonj/Highlight-Indentation-for-Emacs.git . in, say, ~/.emacs.d/highlight-indents and add (add-to-list 'load-path "~/.emacs.d/packages/highlight-indents/") (require 'highlight-indentation) to your .emacs. Then, when visiting a file you can ...


5

Use the FileType autocommand event. See :h autocmd.txt for details. au Filetype python source ~/.vim/scripts/python.vim


5

Use the indent-rigidly command with a numeric prefix. C-u 4 M-x indent-rigidly to indent the region by four spaces, C-u -4 M-x indent-rigidly to remove four spaces.


5

Emacs can do that: load the file into Emacs press Ctrl-space at the top of the file move the cursor to the bottom of the file press Alt-x and type untabify then return press Alt-x and type indent-region then return This will get rid of tabs and indent everything properly. If you need to do this more often and do not use Emacs as your editor, you might ...


5

Press Ctrl+Shift+P, then I, and the option "Indentation : Reindent Lines" should come first. Press Enter and it's done.


4

Try the key binding C-x TAB (aka C-x C-i) which is bound to indent-rigidly, which indents a region by a single space. So, you'd indent by two by pressing that twice setting the region around the code you want to indent and typing: C-x C-i C-x C-i Or, you can pass a numeric prefix with C-u 2 C-x C-i To get 4 spaces, do a prefix with 4 C-u 4 C-x C-i ...


4

You'll have to use two styles for this. For example you could change the "standard" style adding an indentation for the first line as described in the Microsoft Office Online help. Basically you'll have to go in "Indents and Spacing" and under "Indentation" click "First line" from the Special list. In the "By" box, set the amount of indentation. Then, ...


4

In the terminal, Vim cannot distinguish between typed text (where you want automatic indenting), and pasted text. So there's the 'paste' option (and 'pastetoggle' to simplify handling), which when set disables auto-formatting and -indenting. An alternative is using graphical GVIM, which can detect that. Or, you use Vim's clipboard access (if configured and ...


3

Figured it out. Setting "trim_automatic_white_space" to false (true by default) creates the behavior I want. Nice to know there was so much thought put into this editor as to include that option.


3

I believe that the problem is with the default styling of Notepad++ for CSS files. Go to the menu entry of Settings / Style Configurator, then click on CSS and TAG, getting this : You will notice that the font used is @Batang (which I personally never heard of or used). This font does not look like it is a monospace font. Change the font to the default ...


3

I need to remove one level of indentation when coding I use a variety of text editors such as Geany, N++, gedit, and Code::Blocks Notepad++ Select the lines you want to "unindent" and press shift+tab Geany Select the lines you want to "unindent" and press shift+tab or ctrl+u gedit Select the lines you want to "unindent" and press shift+tab ...


3

One option is to use :set formatoptions+=n in conjunction with a custom formatlistpat. The n option reformats numbered lists, prepending the equivalent number of spaces on wrapped lines. It can be adapted for use in this case by defining an appropriate list leader: set fo+=n let &flp='\w\+> ' To illustrate the effects, consider the following ...


3

While your well-intentioned search for a "command-line tool" is perfectly fine, unfortunately I think any truly viable solution to this problem is going to involve writing some code yourself, or at least leveraging existing code (such as an XML parser/generator). In the comments, have posted a few things you can try that may or may not get you the exact ...


3

Normally, the tab key inserts a tab character (character 9) into the document, which means that the insertion point is moved to the next tab stop. As you probably know, you can add/remove/adjust tab stops manually using the horizontal ruler. Among other things, you can make tab stops aligned in different ways. For instance, by default, in the header/footer, ...


3

If you use Vim there is Super Shell Indent : Improved indentation for shell scripts.


3

See this hint on the vim wiki for how to have correct indention even for empty lines. If you just want to keep the previous indent (ignoring what vim calculated as the correct indent) use let ind = indent(prevnonblank(v:lnum - 1)) like explained in a comment under the same wiki entry.


3

I've got this in my .vimrc: set comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-,fb:[+],fb:[x],fb:[-] If I remember correct, add this line in your .vimrc and the job will be done: set comments +=fb:- For a detailed explanation try: :help comments


2

If you have the n flag set in formatoptions (e.g. with set fo+=n), Vim already knows how to format lists with numeric bullets. formatlistpat (short name flp) is the regex Vim uses to match this, so what you need is to enhance that regular expression. This should do the trick for you (but only adds support for - bullets): set ...


2

C-x C-x mark the code and then M-x indent-for-tab-mode That's the save if you have pressed tab for every line.


2

You can also use Rectangles. Mark the beginning of the region with C-Space, go to then end of the region and then type C-xrtRET. Example: v----------------------- cursor position blabla bla bla bla bla bla bla bla bla bla C-SpaceC-nC-n blabla bla bla bla bla bla bla bla bla bla ^----------------------- cursor position C-xrtM-2RET blabla bla bla ...


2

Take a look at vim-indent-object.


2

For the built in solution I like to add the option single_line: false to the key binding, as suggested by peter on this StackOverflow thread. { "keys": ["ctrl+k+d"], "command": "reindent" , "args": {"single_line": false}} But this does not add new lines, as you should expect on some XML and HTML code editing. For those you should follow Tom's answer and ...


2

This seems to work: imap <BS> <Left><Del> Update: That makes backspace behave oddly at the left margin. This fixes that problem: set whichwrap+=[


2

in the menu bar, click LaTeX -> Customize AuCTeX -> Browse options. In there, go to the TeX Indentation group node and follow it. Within the group, activate the Latex Indentation node to make the options visible. Change the Latex Indent Level variable from 2 to 8; set for current session (to avoid messing thing up if they don't turn out how you hope, give ...



Only top voted, non community-wiki answers of a minimum length are eligible