Questions tagged [indentation]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
60 views

How to have the cursor at the right indentation when editing PHP/HTML

When I'm working with HTML in a PHP file and I press enter while in INSERT mode, my cursor goes to the start of the next line instead of going at the right positive therefore I have to press tab to ...
0
votes
1answer
102 views

'filetype plugin indent on' breaks indention [closed]

Using vim 8.*, I am using these plugins: html5.vim polymer-ide.vim supertab vim-javascript In my vimrc.local file if I enable filetype plugin indent on it breaks my javaScript indention but makes the ...
0
votes
3answers
216 views

Substitute tabs for equivalent number of spaces

N.B I use the word blank here due to lack of a better word. By blank I mean the remaining part of a tab that is visualized after the starting part. Please feel free to edit this question. I know ...
0
votes
1answer
91 views

LaTeX indent for \iff error in vim

With the minimal vimrc (with vimtex plugin): set nocp filetype plugin indent on syntax on set st=2 set acd set wildmenu set wildmode=longest,list,full let $USRPLUGD=$HOME.'\vimfiles\myvim\plugged' ...
0
votes
1answer
258 views

Indentation command `gg=G` for 'compressed' HTML doesn't unfold tags

Sometimes I copy 'compressed' HTML from TEXTAREA an I get code for ex. like this: <html><body><h1>header1</h1><p></p> <p></p> <div><p></...
0
votes
1answer
73 views

Disabling indentation for filenames without suffix

VIM's Wikia documentation states that you can disable indentation for certain filestypes by inserting the line let b:did_indent = 1 in the file ~/.vim/indent/<filetype>.vim where <filetype&...
0
votes
1answer
41 views

Indentation script does not work for all occurrence

I have following c.vim file: imap {<CR> {<CR>}<Esc>O imap [ []<Left> imap # #include<><Left> command F %s/\v(\w) ?(\+|-|\*|\/|\>\=|\<\=|!\=|\=|\=\=) ?(\w|-)/...
0
votes
2answers
82 views

Vim: Aligning insertion point with left side of column

Suppose I have this (where my insertion point is designated "|"): col1 col2 thing oeueaoue| another something test What keystroke(s) would I use so the insertion point jumps to ...
0
votes
1answer
68 views

Going to newline pulls existing code to beginning of line

I'm not that experienced with vim. I've been working with some html/php in macvim and there's this annoying behaviour that I don't know how to control. See below. x denotes the current position of the ...
0
votes
1answer
486 views

Pseudo-Indent (two spaces) Multiple Lines

Basically, I need to indent a block of R code. Unfortunately, vim's tab size is bigger than the two spaces that I'm using. Is it possible to accomplish this without hitting the space bar twice for ...
0
votes
1answer
745 views

Temporarily disabling Smart-Tabs

I'm using https://github.com/vim-scripts/Smart-Tabs/blob/master/plugin/ctab.vim through Vundle. How can I temporarily disable it (preferably more readily than by commenting out the bundle and ...
0
votes
1answer
1k views

How to correctly indent when beginning a new line below the cursor ('o')? [duplicate]

Screenshots My problem I am working on a js file, using eslint as my linter with the ale plugin, configured using the airbnb standard which mandates 2 space indentation. When I open a new line by ...
0
votes
1answer
190 views

Run command on all .JS files in a directory recursively?

Someone at my workplace committed non-indented JavaScript I have the VIM plugin autoformat installed and want to run :Autoformat on all .js files in my project directory, how would one do this?
0
votes
1answer
200 views

indent an existing unindented file as per some indentation commands supposedly written for autoindenting new files

I have created some indentation commands like set shiftwidth=4, set autoindent and so on.... in my .vimrc file in my home folder and I'm able to get new files auto-indented happily. What I want to ...
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. ...
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 ...
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 ...
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 ...
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 ...
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
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
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 ...
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
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 ...
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
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 ...
0
votes
0answers
18 views

Is there a way to automatically reindent a selection while preserving relative indentation?

Suppose that I have a file that looks like this: aaa bbb ccc If I select lines 2 and 3 in visual mode and reindent with =, the result is everything in the same line: aaa bbb ccc Is there a way ...
0
votes
2answers
37 views

How to make the indentation more smart

I'm using vim to code and I set autoindent in my ~/.vimrc. Now, if I code as below: if (a == 1) {| // the cursor is here and I type ENTER } After typing the ENTER, the code becomes as below: ...
0
votes
0answers
47 views

vim disable behavior special tags (eg script)

When editing html, vim applies different rules when inside certain tags (like script/pre/style). I want to have the normal html rules when inside a script tag (using handlebars, and I don't write any ...
0
votes
0answers
99 views

How do I get Vim (with TComment) to do proper block comments in OCaml?

(I have TComment installed, and I'm on NeoVim 0.4.0.) Given this code, for example: let mem key st = let is_matching_key = function | Positional _ -> false | Flag f -> f.name == key ...
0
votes
0answers
105 views

In PHP files, how can I auto close HTML tag pairs and indent the new line?

I have been a Vim user for several years now and I haven't been able to find a solution to this issue. There have been a lot of questions on the internet that try to address it, but none of the ...
0
votes
1answer
119 views

inoremap inserts unwanted tabs

I recently made myself custom insert mode keybindings to type faster in LaTeX. However, When I use them, Vim adds tabs that weren't part of the original keybinding. Example: Here is my inoremap: ...
0
votes
1answer
116 views

Automatically reindent lines filtered through formatprg

I have following xml file: <?xml version="1.0" encoding="UTF-8"?> <graph id="G" edgedefault="undirected"> <edge id="e6" source="n5" target="n4"> <data key="d1">1.1</...
0
votes
1answer
280 views

How to change 4-space indentation when using "kotlin-vim` plugin [duplicate]

I just installed kotlin-vim plugin. The plugin looks like using 8-spaces indentation. How can I change it 4-spaces indentation? (To indent all codes I used gg=G. Maybe I'm using wrong way for indent ...
0
votes
0answers
123 views

indentation different on different computers

If I indent the following script with gg=G: #!/usr/bin/env bash while true; do case "${1}" in -h) usage; exit 0;; -b) branch="${2}"; shift 2;; -t) build="${2}"; shift 2;; ...
0
votes
1answer
416 views

Ruby indentation: align multiline method chains on the leading dot?

Vim indents Ruby multiline method-chains like: object.read .write .rithmetic I'd like to make it align the dots instead: object.read .write .rithmetic I haven't been able to find a ...
0
votes
0answers
180 views

Using single quotes blows up syntax formatting in .js

Just noticed that using single quotes in javascript blows up automatic formatting sometimes: See the public/sass/*.sass line: Double quotes: gulp.task('compile-sass', function(){ gulp .src("...

1
3 4 5 6
7