Questions tagged [indentation]

For questions about prefixing lines with whitespace to aid in readability.

Filter by
Sorted by
Tagged with
5
votes
1answer
575 views

Count the number of whitespace in the beginning of a line

How to count the number of whitespace in the beginning of a line ( aka indentation ). eg: foo() foo() And then :command(2) 4
5
votes
2answers
777 views

Vim conceal indentation. Replace indentation spaces with utf-8 chars

I use four spaces for indent. I would like to replace the indentation with some UTF-8 chars. What I have: 1. def foo(bar): for jaffa in bar: print jaffa 2. var foo = function(bar){ ...
5
votes
2answers
101 views

Can I make the indent commands take an additional count that doesn't affect the motion?

Let's say I'd like to indent the current line 4 times. (Not 4 spaces, 4 indent commands). As far as I can tell, the shortest way to do this is >>... (Indent once, repeat three times) This ...
5
votes
1answer
3k views

Expand <TAB> into 2 spaces when and only when editing HTML

My current configuration makes vim automatically expand TAB to 4 spaces for me: " Define tab as 4 spaces " Taken from http://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces set tabstop=4 ...
5
votes
1answer
4k views

Incorrect auto-indent in python code

I have a following python code, which contains both 4 space and 2 space indents. class Foo(object): def __init__(self, flag = False): if flag: print("hello") ...
5
votes
1answer
194 views

Keep beginning of current fold on top of the screen

I've googled around but can't find anything about this. There is a case: when I navigate deep down through large blocks of code in (for example) python, it would be useful to see which method, ...
5
votes
1answer
1k views

Indentation of preprocessor directives

In my vimrc I have the following line, which figures all the indentation of my files. filetype plugin indent on When writing C programs sometimes I use preprocessor directives like #ifdef foo and #...
5
votes
1answer
636 views

Indentation in Latex within a list after an equation

Here is a minimal .tex file: \begin{document} \begin{itemize} \item Here is an equation: \begin{align*} x = y \end{align*} \item Here is another item ...
5
votes
4answers
3k views

Delete indenting spaces one at a time

I want to be able to delete indenting spaces one at a time. If I set shiftwidth to 4, it deletes 4 spaces at a time if vim counts them as indentation. Setting shiftwidth to 1 fixes the problem, but ...
5
votes
2answers
1k views

Indent a markdown list item?

I am frequently editing markdown files, and when dealing with multi-line items in hierarchical lists, it would be great to have a rapid way to indent or un-indent a list item. For example, how can I ...
5
votes
1answer
295 views

When moving text to new line, changes indentation for both lines

I am seeing this in Vim 7.3. I have autoindent on. Sometimes, when I move some code to the next line, the indentation of the line it was originally on changes, and then the newly created line is set ...
5
votes
1answer
75 views

Adding new characters cause splitting line into many lines

I'm analyzing a lot of logs using VIM version 7.3 (2010 Aug 15, compiled Sep 24 2013 13:45:11). Recently I obtained logs that look like this: 3521:2015-09-28T09:18:36.922557+00:00 192 [info] » ...
5
votes
1answer
93 views

gq in visual mode indents just first two lines of enumeration

Some markdown as an example. I select the following paragraph in visual mode and press gq. The result is: - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor ...
5
votes
1answer
2k views

Search and replace, special pattern for indent (ex: newline = '\r')

I am cleaning up some minified css. I found this article helpful for adding a newline before/after a search match. This SO thread has a pretty exhaustive list of ways to indent with VIM, but it DOES ...
5
votes
1answer
177 views

How to wrap plain text honoring existing text indent?

With at least these settings: expandtab textwidth=79 sw=4 ts=4 fo=tcq If I have a long line of text that starts with a * (like a C/javadoc comment) it will honor the current indent level when I gqq, ...
5
votes
1answer
733 views

Vim auto indentation

I am using Vim with Pathogen, vim-jsx, and vim-javascript. I have trouble getting the correct indentation. When I am breaking one line that is too long into several pieces (without adding new blocks),...
5
votes
1answer
669 views

vimrc tab behavior when noexpandtab and softtabstop is less than tabstop

Questions In the following example: Why in the first line, a \t is inserted but only 4-col blank is displayed? Shouldn't it be 8 according to tabstop? Why the two <TAB> hits in the first line ...
5
votes
1answer
90 views

Auto-indenting copied text

I would like to auto-indent text blocks that I have just put. At a minimum, I would like to retab the new block of text, since otherwise I sometimes end up with tabs in files that shouldn't have tabs ...
5
votes
1answer
400 views

Why does the "rst" filetype automatically indent subsequent list items?

I've been having trouble understanding the behavior defined in GetRSTIndent() in indent/rst.vim. I'm specifically using Neovim v0.2.2, but I believe this file has not changed between Vim/Neovim. ...
5
votes
0answers
71 views

Make Vim ignore first character in line while indenting

Whenever I have to edit Perl Mason files, I always have problems indenting lines due to Perl code starting with %. For example: <div> <div> % if( !$something ) { <...
4
votes
3answers
342 views

How can you indent your current file without losing your cursor position?

I was reading that the way to indent in vim is a gg=G sequence. This however loses my cursor position. How can I indent my file without losing my cursor position?
4
votes
3answers
588 views

How do I comment out lines without changing indentation?

I use Vim to write my Python source and use the debugging library pdb. Let's say I have this code with break points commented out: import pdb #pdb.set_trace() def func1(): #pdb.set_trace() ...
4
votes
3answers
532 views

How can a character be inserted during an edit session by its Unicode numeric value?

I'm trying to set up a plugin to enable indentation guides, following an answer to this question. The plugin is Yggdroot/indentLine. It has instructions to set up a custom glyph to be shown instead of ...
4
votes
2answers
1k views

Paste word on new line with indentation from current line

Using ]p in normal mode, I can paste a yanked line of text on a new line below the cursor with indentation equal to the current line. Using the :put command, I can paste a yanked word as if it were a ...
4
votes
1answer
3k views

Vim indent using "=" inserts 2 tabs

If I try to indent a code using visual mode or ggVG= vi automatically inserts 2 tabs instead of just 1. for example: // inside main for (int i = 0; i < 10; i++) { test += i; } changes to: ...
4
votes
4answers
882 views

How can I easily indent inline comments?

I frequently have inline comments for variables: var1 = 0 # Var 1 var2 = 0 # Var 2 var3 = 0 # Var 3 var4 = 0 # Var 4 (This is in python, for example, but this question applies to C-Style ...
4
votes
1answer
1k views

How do I disable intelligent indentation in HTML files?

I've created a blank example.html file and I open it in Vim, and I add the following contents: <div> Still in insert mode, at the end of the line, if I press enter, the new line will ...
4
votes
1answer
432 views

Set tabulation size when function's parameters are written on multiple lines

I need to respect a coding style with 4 spaces tabulations and I want to fit with the 80 columns rule. I get then the case where some function need their parameters written on several line : int ...
4
votes
1answer
192 views

augroup end indentation

When I'm editing my vimrc, if I gg=G vim autoindents nicely except where augroup is involved I end up with augroup movingBackup au! au BufWritePost * call WriteBackupFile(expand("%:t"), ...
4
votes
1answer
397 views

Why does Vim force programming indentation when in "gitcommit" filetype?

I found that when I am using Vim to compose git commit messages (which I have been doing for a very long time now) that there are occasionally some quirks. For example today I wrote a commit message ...
4
votes
2answers
1k views

Why does vim still auto-indent LaTeX after I set noai noci nosi?

I want to disable autoindent and smartindent for LaTeX so I did :set noai noci nosi When I open a brand new mwe.tex, filetype=plaintex and there is no auto indent magic. When I then enter some code,...
4
votes
1answer
403 views

multi-line insert after indentation whitespace

if I have a list of indented text test test test test test test test test test test test test test test and I wanted to convert it to a markdown list - test test - ...
4
votes
1answer
223 views

indent command does not indent matched lines

I have file where I would like to indent all the lines between curly braces: html { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } body { line-height: 1....
4
votes
2answers
1k views

Can I get vim to fold comments when using foldmethod=indent

When editing Python files at work I have to include 20+ lines of boilerplate legalese at the start of the file. "start of the file" is not that strict: I'm allowed to include the Python docstring, and ...
4
votes
1answer
674 views

How can I specify a command-line command with options as an equalprg?

I am trying to set up the Node.js version of js-beautify as an equalprg command when I am editing a JavaScript file, so that the Vim = indent commands reflow my JavaScript at the same time. Initially,...
4
votes
1answer
398 views

Vim highlighting random indentations

As seen from the image, Vim decides to highlight those indentations for no reason. I've tried :noh and :set nolist (:set list seems to make it go away, but I don't want indentation marks) from a ...
4
votes
1answer
1k views

How to make a newline without autoindent

Is there a command to make a newline without the autoindent? In other words, I want o and O to normally autoindent, but is there another command that will not autoindent for just the duration of that ...
4
votes
1answer
1k views

Autoindent second line of plain text bullet list item

When using plain text I write bullet lists like this (second and further lines indented with two spaces): * blah blah blah blah blah * yadda yadda yadda Problem is, when I start out a new bullet ...
4
votes
2answers
1k views

Remove unecessary indents while keeping the relative indentation

I am looking for a transformation that would change this text: text indented text double indented text indented again to: ...
4
votes
1answer
413 views

How to check whether the cursor is at the boundary of a syntax item for indentexpr?

I'm writing my own indentexpr to indent my code, the indentexpr is run in a sandbox, so one important point is that I cannot change the text content. I have set up the syntax highlighting for quoted ...
4
votes
1answer
227 views

Motion to jump back one level of indentation, not including blank lines

I've been authoring a lot of F# in Vim lately. Like Python it is pretty strictly indentation-based. However, unlike Python mode for Vim, it does not appear that the standard F# Vim plugin supports any ...
4
votes
4answers
2k views

Why is autoindent not applied to my markdown files?

When editing markdown (*.md) formatted files, and making bullet points, upon pressing return I want the new bullet point to be automatically created in the same level under the previous one. ...
4
votes
1answer
2k views

How to make auto-indent XML in vim?

I am thinking on a similar solution, which Eclipse also does: during the editing, the editor tries to always hold in a "well-indented" format of the edited textual data. Ideally, it would happen very ...
4
votes
1answer
967 views

How to change indenting for html files?

I code mainly in 2 languages python and HTML. I currently have the indenting configured for python in my neovim configuration file but I would to know how to make neovim auto-detect the type of file ...
4
votes
2answers
290 views

Get same indentation behavior as opening a new line on an empty line

Whenever I open a line using o or O, the cursor starts at the correct indentation (I'm not sure if vim uses syntax hints for this or just mimics the position of first character of the neighboring ...
4
votes
1answer
1k views

Indenting VHDL as other programming languages

When I write VHDL Vim uses a mix of tabs and spaces which aim to align columns beneath the last parenthesis. For example, Vim will produce something like Inst_IMem: IMem PORT MAP( ...
4
votes
1answer
973 views

Indenting c/c++ using lisp indentation style

I want to write c++ code in vim using lisp indentation style (closing curly braces on the same line as last statement) but I can't figure out how to configure indentation to use that style. Is there ...
4
votes
0answers
98 views

Can I get vim to indent correctly after a here document?

In an account with just an emtpy .vimrc, under Xubuntu 20.04 and vim 8.1, I get strange indentaion after my here document if I reindent with gg=G I've boiled down an example from some pretty tangled ...
3
votes
2answers
2k views

Can vimwiki be made to treat list indentation the way vim-notes does?

I've looked through the vimwiki documentation and a few questions here on SO, but don't see how I can manage this. In vim-notes, hitting TAB within a list indents the entire list item. In vimwiki, ...
3
votes
6answers
1k views

Indent on New Line between HTML/XML Tags

I'm currently using imap <silent> <C-c> </<C-X><C-O><C-X><Esc>F<i as per this post and this page to close <></> tags of any kind with <C-c&...

1
2
3 4 5
7