5 votes

Why is indentation on Github different from indentation in my Neovim?

Note that almost every tool that renders text with tabs has a way to configure tab size. It's the case with neo/vim, but also with github. See the current official documentation and its screenshots. ...
Luc Hermitte's user avatar
  • 17.2k
5 votes
Accepted

Why is indentation on Github different from indentation in my Neovim?

You indent your code with tab (expandtab = false). You have configured Neovim to show tab as 2 spaces (tabstop = 2, shiftwidth = 2). It seems that GitHub display tab as 8 spaces. If you want to align ...
Vivian De Smedt's user avatar
4 votes
Accepted

How to turn off auto indenting while editing a LaTeX file?

To disable auto indentation you can do: :set noautoindent :set indentexpr= If you want to make automatic for all LaTeX files you could add a tex.vim file within ~/.vim/after/indent/ folder with the ...
Vivian De Smedt's user avatar
3 votes
Accepted

Why four spaces turn into two when copying lines from gVim into LibreOffice?

I believe the problem is that the font you use in OpenOffice is not fixed width. I suggest that you use you switch in LibreOffice to Lucida Console or Courrier to verify my hypothesis. Remark: the ...
Vivian De Smedt's user avatar
3 votes
Accepted

How to have different indentation styles depending on the file?

By file type If the value of these option only depend on the filetype you can override the default for a specific file type (e.g.: python) by adding a ./vim/after/ftplugin/filetype.vim with the ...
Vivian De Smedt's user avatar
2 votes
Accepted

Wrong indentation in brackets

This automatic indentation is controlled by the indentexpr option. For python the default procedure is configurable and if you set the following global variable g:pyindent_open_paren to shiftwidth() ...
Vivian De Smedt's user avatar
2 votes

How to fix indentation for *.nix files?

I believe you have the odd behavior because for nix file no specific indentation rules are defined and you end up with the c indentation that is odd for nix. To get a basic indentation based on the { ...
Vivian De Smedt's user avatar
2 votes
Accepted

How can I make (Neo)Vim wrap lines in respect to indentation?

To enable this feature, you can add the following line to your (Neo)Vim configuration file, typically located at ~/.vimrc for Vim or ~/.config/nvim/init.vim for Neovim: set breakindent If you'd like ...
Hassan Alsheikh's user avatar
1 vote
Accepted

Trouble in overriding `indentexpr` in neovim

My recommendation is to move your code into: nvim/after/indent/lua.vim setlocal indentexpr= The indent folders are processed after the ftplugin folder and are indented to be used to set the ...
Vivian De Smedt's user avatar
1 vote
Accepted

Indentkeys Tab behavior

I would do: inoremap <expr> <Tab> getline('.') == '' && line('.') != 1 ? "\<Bs>\<Cr>" : "\<Tab>" It is based on the 'fact' that Vim indent ...
Vivian De Smedt's user avatar
1 vote
Accepted

change behaviour of > / < and >> / << to insert / remove only leading tabs

Here's the code that does the job (only > and <, but you can easily add >> or <<). Assuming you have preserveindent set, it works in visual mode, as well as range motions e.g. >2j ...
Hoblovski's user avatar
  • 303
1 vote

What's the Vim option to make indentation matches source file?

My suggestion would be to install vim-sleuth that guess the indentation settings of the file and adapt the Vim configuration accordingly.
Vivian De Smedt's user avatar
1 vote

move (motion or visual selection) to own line and indent

With https://github.com/tpope/vim-surround, that's cSbb/cS((. Manually, I'd go for vibc<enter><esc>[p==. Whatever solution you like, you can create a mapping for it: " ~/.vim/after/...
D. Ben Knoble's user avatar
  • 25.8k
1 vote

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

Expanding on Martin's answer, the right expression seems to be inoremap <expr> <Tab> getline('.')[: col('.') - 2] =~ '^\s*$' ? "\<Tab>" : repeat(' ', shiftwidth() - ((...
Lehel Bernadt's user avatar
1 vote

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

I have remapped i (and other keys to enter insert mode) to run together with reindent command (:h i_CTRL-F). noremap i i<c-f> Note that in order for it to work, cindent (:h 'cindent') has to be ...
ivanjermakov's user avatar
1 vote

Paste word on new line with indentation from current line

Use o to create a new line, then use <c-r> to enter register mode in insert mode, and finally press " to invoke the unnamed register to paste the copied content.
蔡政特's user avatar

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