Questions tagged [indentation]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
21 views

Understanding what macro / format / etc ... vim is running [closed]

I'm in a situation with gVim where when I type any alpha letter after a space vim will insert a newline before the character I typed. It's infuriating. Doubly so because I can't understand why this is ...
  • 101
0 votes
0 answers
19 views

JavaScript HTML Template Literal Indenting

I have https://github.com/Quramy/vim-js-pretty-template installed to handle syntax highlighting for template strings marked with /*html*/ But indenting does not work correctly - I end up with ...
0 votes
1 answer
19 views

Autoindent uses tabs after paste mode

My .vimrc: :set tabstop=2 :set shiftwidth=2 :set ai :set expandtab My workflow: vi filename type space spacetextenter, cursor is now under 't', indented with 2 spaces. As expected. :set paste paste ...
  • 103
3 votes
2 answers
106 views

Make Vim _really_ work with both spaces and tabs

Here is what I use for indentation: set autoindent set breakindent set expandtab set smarttab set shiftround set shiftwidth=2 softtabstop=-1 " or maybe shiftwidth=2 softtabstop=8 " https://...
0 votes
0 answers
29 views

Do I need the contents of the indent and ftplugin directories in my configuration?

While I have been using nvim (on Linux) for some time, I have only recently started using gvim (on Linux and Windows). I have noticed that on the Windows version of gvim there are directories amongst ...
  • 129
0 votes
1 answer
106 views

Indent changes when using CoC, how do I stop this?

I have set up my init.vim file to always use tabs as indentation by adding this to it: set tabstop=4 set shiftwidth=4 set noexpandtab Ever since I installed CoC to use Rust's language server, it ...
3 votes
1 answer
31 views

How to indent C function parameters like curly braces and not with cino-(

From :h cino-(, I see that we can only indent the parameters for the function calls with respect to the opening bracket. This is problematic for functions with long names or within multiple namespaces....
  • 3,391
0 votes
1 answer
23 views

Indentation is messed up when pasting code

I find that the default indentation support for pasting is lacking. For example , If I use ]p for the following(copied using V) : try: l=None if 1: df = ...
  • 1,164
2 votes
1 answer
46 views

How can I make Tab insert tabs at the start of the line only, and spaces after text?

What I want to achieve I would like to setup vim such that tabs are inserted on lines until another character is inserted, after which, further tabulation results in spaces (similarly to expantab). ...
  • 23
2 votes
1 answer
148 views

Force convert spaces to tab in all file type [duplicate]

So today I'm having some problems with vim. I wanted to use tab when I press the tab key, and a tab is equal to 8 spaces. This is what I added to my /etc/vimrc file: :set noexpandtab :set tabstop=8 ...
1 vote
0 answers
26 views

False indentation after line continuation in if-else clause for `sh` filetype

I have shell script file (filetype=sh) like if [ -f filename ]; then echo "file exit" | \ cat - else echo "file not exist" fi When I select the block and apply ...
  • 170
3 votes
1 answer
44 views

Java Code Conventions: How to set up autoindent

As recommended by Oracle's Java Code Conventions, I try to avoid lines longer than 80 characters. For this it's of course often necessary to break lines, and the document contains some general ...
0 votes
0 answers
39 views

Empty line indentation for Python

Whenever I press o or O, VIM starts the line with the desired indentation. At work, people have decided that they want empty lines to be indented as if it contained code, such that code can be copied ...
0 votes
1 answer
56 views

vimtex: configure to indent '[ ... ]' and '\[ ... \]' blocks

When setting indentation using vimtex, I meet some problem. I set the option g:vimtex_indent_delims to indent [...] blocks. let g:vimtex_indent_delims = { \ 'open' : ['{','(','['], \ '...
  • 113
1 vote
1 answer
79 views

vimtex: fully indent a '{ ... }' block

Concerning indent in vimtex, it has some settings controlling indenting of delimiters, the option seems to be g:vimtex_indent_delims. However, I would like to not only indent the text between opening ...
2 votes
4 answers
344 views

How to move cursor up to nearest upward smaller level of indentation

Imagine my cursor is where the ^ is in this document: { "first": [ { "second": { "third": [ "fourth" ] } }, {...
  • 1,737
1 vote
1 answer
135 views

`:call append!` -- how vim insert line (append or setline) while respecting indentation

I want to put a string function output in my vim when press xx. My current working example is: nnoremap <silent> xx :call append('.', 'string_output')<CR> However, this put a line without ...
  • 25
7 votes
4 answers
675 views

Vim plugin where the first lines in the editor show the first line(s) with less indendation that are not visible

I would like to either find or write a plugin that does the following: Assume I have this python code: def foo(a,b,c): # comment [100 lines that do stuff] for i in range(N): [100 ...
  • 279
0 votes
1 answer
33 views

Vim treats paths with wildcards( /*) as C-style block comments and applies weird indentation

Vim 8.1 from Ubuntu 20.04 thinks /* in include /etc/nginx/conf.d/*.conf; is a start of a C-style block comment and gives wrong indentation in default nginx.conf file when using '=': http { ...
1 vote
0 answers
100 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). ...
2 votes
2 answers
112 views

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
0 answers
44 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. ...
4 votes
1 answer
4k 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 &...
  • 99
1 vote
1 answer
30 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 [ ...
  • 13
0 votes
2 answers
91 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 ...
  • 781
3 votes
1 answer
103 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 ...
  • 131
0 votes
0 answers
80 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 ...
  • 2,018
0 votes
0 answers
27 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 ...
2 votes
1 answer
85 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
0 answers
25 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 ...
1 vote
1 answer
28 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 \ ...
  • 113
0 votes
0 answers
88 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
0 answers
28 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
2 answers
87 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() { ...
  • 781
1 vote
1 answer
125 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,737
1 vote
1 answer
84 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
1 answer
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 ...
  • 143
1 vote
1 answer
43 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
1 answer
153 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 ...
  • 251
3 votes
1 answer
287 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 ...
  • 227
1 vote
1 answer
158 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
1 answer
43 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
0 answers
124 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 ...
  • 213
1 vote
1 answer
428 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 ...
  • 151
0 votes
1 answer
26 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 ...
  • 1,746
2 votes
1 answer
421 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} };...
  • 1,746
0 votes
1 answer
85 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 ...
  • 1
0 votes
0 answers
95 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> ...
  • 101
0 votes
1 answer
99 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
0 answers
23 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 ...
  • 145

1
2 3 4 5
7