Questions tagged [indentation]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
35 views

vim doesnt recognize html in string in filetype php. same thing with php code in filetype html

Ive had no luck solving these issues for quite a while now. Problem1 When writing HTML inside a string in a file with filetype=php, the HTML is not recognized (i.e., it has no highlighting or indent). ...
0
votes
2answers
80 views
+100

How to remove this weird default indentation?

If I do gg=G on a file with the following text - 2018-2019 ICPC Northwestern European Regional Programming Contest (NWERC 2018) - 2020 ICPC Universidad Nacional de Colombia Programming Contest - ...
0
votes
0answers
23 views

How can i get visualize line indent every time i use tab or go to new line

I set set listchars=tab:\│\ set list to my vimrc and it shows like below But when I go to another file it doesn't have a vertical line indent. It just affected 1 file, I have no idea about this. ...
2
votes
1answer
205 views

How does smarttab actually works?

Yes, I'm aware of what :h smarttab says, but I still cannot figure it out. " My vimrc set backspace=indent,eol,start set tabstop=8 " I always keep this 8 set shiftwidth=4 set softtabstop=-1 &...
0
votes
0answers
6 views

Javscript auto indentation with Django HTML Templates

When trying Javascript within tags in a Django template, the behaviour is absoutely terrible. Pressing enter may mess up the line above and below. I spend more time fighting the crazy indentation ...
1
vote
1answer
22 views

How to totally close all the auto indent

In my case, I was writing a tex file. After Closing some auto indent settings set noai noci nosi filetype indent off filetype plugin indent off But vim still gave me 2 tab indent when I type { or [ ...
0
votes
2answers
45 views

Delete until the start of next visible line?

I'm using MacOS. As title, for example before the command: $('h1#title') .css({'font-size': '80px', 'text-align': 'center'}_)_ .text() .testing() .tset() (Notice that the blank line ...
3
votes
1answer
47 views

LaTeX: turn off text wrap and auto indent in maths environments

I use vim with vim-latex for editing latex files. I always have hard wrapping enabled using set tw=80. I also have the default vim-latex auto indent settings enabled. I wonder if there is a way to ...
0
votes
0answers
43 views

Reindent html with xmllint

I'm trying to reindent current HTML file with this command from inside vim : :!xmllint --html --format % 2>/dev/null But, all it does it displays the output to stdout without actually modifying ...
0
votes
0answers
22 views

Custom indent minified file

At work I'm forced to work on custom mapping-files which map relations between objects of different systems. These mappings, which are basically Jinja templates, are unfortunately stored in single ...
1
vote
1answer
48 views

Inserting abbreviation from file

First, I apologize if this is a trivial question. I have the following file (main.ab) defining a Python snippet: def main(args): ... if __name__ == '__main__': args = ... main(args) And ...
0
votes
0answers
24 views

How to configure what happens after hitting enter inside parentheses [duplicate]

| - cursor position when I edit JavaScript file: function(|) pressing "Enter" gives function( | ) Which is good for me. But when I edit R file it gives: function( | ) How can I ...
0
votes
0answers
38 views

How to selectively indent Sphinx .rst (reStructuredText) files

As per indentation section of the Style guide for Sphinx-based documentations: Indent with 2 spaces. Except: toctree directive requires a 3 spaces indentation. So how to set Vim to auto-indent the ...
1
vote
1answer
23 views

vimscript to insert function result is not inserting with proper formatting

I have a function that I want returning pre-indented xml: function! InsertStep() let stepTemplate = "<step index=\"\">\n \ <description></description>\n \ ...
0
votes
0answers
31 views

How to apply existing indenting rules to new file type?

I've been happily using vim for years for C and C++ projects. My code formatting/indentation rules have been cobbled together over the years based on solutions to at-the-time needs...which is to say, ...
0
votes
0answers
22 views

Keep whitespace from indent even on empty line [duplicate]

I am working with python files with filetype indent on. I like a lot of the default indenting features for python, but I would like vim to keep the tabs, even on empty lines. For example, using set ...
0
votes
2answers
61 views

Space indent disappear when `o`/`O` follows by <Esc>

I will try to describe my problem with an example. Given the position of my cursor at: function Test() { return ( <div>█ </div> ) } NORMAL When I press o: function Test() { ...
0
votes
0answers
21 views

Change indentation behavior when `:filetype plugin indent on` is set

Tested with vim --clean \<filename>.py, then did :filetype plugin on and :filetype plugin indent on. To make code look better, i wanted to write something like this for a dictionary: test = { ...
0
votes
0answers
62 views

How to indent C code in vim correctly?

I am trying to indent the C code in vim. I have understood from one of the vi stackexchange post that we could indent the C code by pressing gg to go to the first line and then press = and then press ...
0
votes
1answer
31 views

How to use tab for indent in indent function while expand tab was set?

When expandtab is set, how to let the indent function defined in file vim/indent/xxx.vim use tabs, rather than spaces to indent lines? Edit: Here is the background. I have use vim's built-in CHANGELOG ...
1
vote
1answer
36 views

Replace two space indentation with tabs

I'd like to replace all two-space indents with tabs I can't do :%s/ /^I/g bc this replaces within lines too. I can't do :%s/^ /^I/g bc this replaces only the first two spaces of each line, not each ...
1
vote
1answer
40 views

Re-indent for eruby files does not work

I am trying to re-indent a foo.html.erb file, however when I do gg=G everything gets aligned to the beginning of the line. I couldn't figure out why that happens. I've tried installing polyglot or ...
0
votes
1answer
13 views

Move the caret to proper indentation inside insert mode in C files when using arrow keys

In insert mode, scope indentation is not taken into account if I navigate rows during insert mode. Example: In such a case, if I would press the up arrow key, Vim would place my caret at the start of ...
1
vote
1answer
42 views

Loading C file overwrites indentation settings in .vimrc [duplicate]

When I open a C file in vim, it seems to think I want 8 spaces worth of indentation, even though I specify my indentation preferences in .vimrc with the below: set expandtab set softtabstop=4 set ...
0
votes
1answer
74 views

Preventing the colon from causing indentation to be deleted

When opening a C file, then even with the vanilla setup on my Linux Mint system, if I type identifier at the beginning of an indented line and then ':' immediately after it, the indentation for that ...
2
votes
2answers
103 views

How to re-indent nginx configuration based only on `{` and `}`?

I want to reindent an nginx configuration file with the following simple rudimentary rules: a { increases indentation a } decreases indentation The idea is cindent is just enough to do it. I have ...
3
votes
1answer
123 views

How can I make fmt return leading spaces instead of tabs?

When I use vim to write regular text (not source code), I often highlight a long line, or a paragraph, and do: !fmt to re-format the lines into proper length lines. I think they up up being 75 ...
1
vote
1answer
66 views

Stop vim from deleting expanded tab as a block of spaces

I am on CentOS 8.1 and using vim 8.0.1763. When I open a python file, e.g. vim tmp.py, I type tab and it inserts 4 spaces (see .vimrc below). When I type delete, it deletes all 4 spaces. I want it ...
2
votes
1answer
25 views

Indentation error on VHDL component instantiation

I'm finding some strange behaviour on indentation in VHDL, and have added a minimum example. It is very strange, as everything else seems to work perfectly with VHDL. Does anybody know how to fix this?...
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 ...
1
vote
2answers
43 views

Where should I put filetype specific options for indentation?

At moment, mostly for random reasons, I have $ cat ~/.vim/ftplugin/c.vim set tabstop=2 softtabstop=2 expandtab shiftwidth=2 smarttab smartindent autoindent cinoptions=g2 and this $ cat ~/.vim/...
2
votes
1answer
22 views

text object for current indentation level? [duplicate]

Say I have an indented block like so int main(int argc, char **argv){ printf ("odd numbers between 1 and 10:\n"); // level 1 for (int i = 1; i <= 10 ; i ++) { // ...
1
vote
1answer
183 views

How to get indentation lines for spaces without loosing chars like quotes in json files

rephrased my question based on Matt's answer and Christian's comment: I really like the indentLine plugin that shows vertical lines to visualize indentation levels. However, when using it, it does not ...
0
votes
0answers
15 views

Indent line in xml after omni-completion

When editing xml, lines are indented when pressing (among others) <, > or <CR> according to the indentkeys setting. For example: <tag> </tag| If the cursor is on | and I ...
0
votes
1answer
37 views

How to make a filetype behave exactly like C++?

I want the filetype .my_cpp and .my_cc to behave exactly like C++ files in Vim. I have the following set: autocmd BufNewFile,BufRead *.my_cc set syntax=cpp autocmd BufNewFile,BufRead *.my_cpp set ...
0
votes
1answer
20 views

Understanding interaction between visual, autoindent, and paste option

Let's start form this faulty C++ source file #include <vector> int main() { std::vector<std::vector<int>> v{ 1,2}, 9,3}, 4,2} }; } which ...
2
votes
1answer
133 views

Understanding indenting rules for C++ files

Why is the following C++ source file indented like this, #include <vector> int main() { std::vector<std::vector<int>> v{ {1,2}, {1,1}, {1,2} };...
0
votes
1answer
36 views

Vim indentation different on linux and macOS

I'm using vim to write in C for college. My .c files need to abide to specific formatting rules. While I'm writing my files on Linux, the .c files will be evaluated on macOS. I noticed that any tabs ...
0
votes
0answers
52 views

`filetype plugin indent on` with `filetype=html` over-indents <script>

Since my last system update (I think), I have noticed this very annoying behavior. # vim foo.html # I go to insert mode, I type (no whitespace except newlines) <html> <head> ...
0
votes
1answer
50 views

Unwanted cascading indentation [duplicate]

I am struggling to regain control of indentation for certain filetypes, particularly when pasting code. I end up with what I call "cascading indentation" which is nearly unreadable. I've run ...
0
votes
0answers
19 views

How to write a function to set nobreakindent when using the Pencil plugin?

I'm trying to get the Pencil plugin to run with the noautoindent and nobreakindent settings. This is what I've tried in my init.vim: + 201 function! s:pencil_enter() + 202 set nobreakindent + 203 ...
2
votes
0answers
29 views

Reformatting a tab in vim [closed]

I am new to vim, and I'm facing an interesting problem. I need to reformat a file so that the indentation is consistent. How do I do this?
2
votes
1answer
444 views

Vim doesn't use default indenting for markdown

My default indent width settings (4 spaces) are not used for markdown files. Whenever I open a markdown file it is indented using 2 spaces. Here are my default indent width settings. In my .vim/vimrc ...
2
votes
1answer
63 views

Automatically indent at the right level when moving to a completely empty line

I have this binding in my .vimrc to trick autointent into actually populating the next line with real characters, so that if I hit enter, leave the line, and click back to it, I can already be at the ...
2
votes
3answers
262 views

How to change indentation in "case" with curly braces? [duplicate]

The default is this: switch(x) { case a: { y(); } } But I need this: switch(x) { case a: { y(); } } With :set cindent and :set cino={-s this is ...
0
votes
1answer
3k views

Fixing tab and space inconsistency

I used < in visual model to do a shift+tab reverse for a code inside loop after I removed the try/except phrase. Now, I get an error: $ python clean_captions.py File "clean_captions.py"...
2
votes
1answer
151 views

How can I have jinja2 indentation and syntax when keeping HTML filetype?

I have emmet installed and some more plugins that are usable on html filetypes, I would like to have syntax highlighting and have indentation for jinja2 while keeping the filetype HTML so my HTML ...
1
vote
1answer
258 views

incorrect auto-indent behavior

In some very specific scenarios, the auto indenter has almost unexplainable behavior that is very annoying. Example with haskell MultiWayIf syntax (cursor is at the "!"): test | test ...
2
votes
1answer
38 views

bad comment behavior in cmake files

When I'm editing a cmake file in (neo)vim I'm getting bad behavior block inserting comment characters. Given this section of text install_license_file( PACKAGE tomcrypt TARGET ...
1
vote
1answer
483 views

Vim mapping to auto-indent when entering inside braces, brackets etc

Which vim mapping/ plugin will help me in auto-indenting when entering inside braces, brackets or any similar characters. For example: Input {press enter} Output { cursor here } I want ...

1
2 3 4 5
7