Kakoune: Python hooks indent when they shouldn't

Created on 6 Jun 2018  路  6Comments  路  Source: mawww/kakoune

Steps

  1. kak foo.py
  2. insert the following:
class Foo:
    pass
  1. place the cursor at the beginning of the first line, go into insert mode, hit enter a few times

Outcome

The second line rapidly disappears off to the right side of the screen

Expected

This, uh, not happening? :p

Most helpful comment

Kakoune has two relevant settings you might want to check: tabstop sets the width of each tab character (inserted with the <tab> key), and indentwidth sets the number of spaces inserted or removed by the > and < commands.

If you're the kind of person who hates tabs for indentation and only wants to use spaces, you'll probably want to map <tab> to something else, and control the amount of indenting by setting indentwidth.

If you're the kind of person who hates spaces for indentation and only wants to use tabs, you'll probably want to set indentwidth to 0 (which means "indent with a tab, not spaces") and control the amount of indenting by setting tabstop.

All 6 comments

There is a x key in the last try statement of the python-indent-on-new-line command in python.kak. It should be replaced by <a-x>.

I'm having a problem with python indentation after colons. So far I've only had this happen in python files.
I'm not doing anything special with tabs in my kakrc except a couple standard hooks for tab completion, removing them doesn't change the behavior. Removing my python filetype hooks doesn't change anything either.

Steps
This happens in insert mode when I press enter from a line ending in colon or I add lines underneath from normal mode (using o).

Outcome
The new indented line has four spaces prepended to it even though I'm using tabs in the file, like so:
(. is a space, >------- is a tab)

>------->-------if foo:
....>--->-------# indent ends here

Expected

>------->-------if foo:
>------->-------# indent ends here

or

>------->-------if foo:
>------->------->-------# indent ends here, even better

Kakoune has two relevant settings you might want to check: tabstop sets the width of each tab character (inserted with the <tab> key), and indentwidth sets the number of spaces inserted or removed by the > and < commands.

If you're the kind of person who hates tabs for indentation and only wants to use spaces, you'll probably want to map <tab> to something else, and control the amount of indenting by setting indentwidth.

If you're the kind of person who hates spaces for indentation and only wants to use tabs, you'll probably want to set indentwidth to 0 (which means "indent with a tab, not spaces") and control the amount of indenting by setting tabstop.

C.f. #2168

@Screwtapello

Works perfectly, thanks!

Mind if I quote your answer on the wiki page on Indentation and Tabulation? Might save people time in the future

Go ahead!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lenormf picture lenormf  路  4Comments

alexherbo2 picture alexherbo2  路  4Comments

fennewald picture fennewald  路  3Comments

alexherbo2 picture alexherbo2  路  3Comments

abitofalchemy picture abitofalchemy  路  3Comments