开发者

What characters are in my python identation sections in vim?

开发者 https://www.devze.com 2023-02-19 02:51 出处:网络
I have this in my vimrc. set listchars=trail:.,tab:>-,eol:$ set nolist noremap <leader>i :set list!<CR> \" Toggle invisible chars

I have this in my vimrc.

set listchars=trail:.,tab:>-,eol:$
set nolist
noremap <leader>i :set list!<CR> " Toggle invisible chars

When I'm programming in Python and I run <leader>i, my identation doesn't show any characters, since it isn't trailing whitespace, neither tabs.

Now, I'm wondering: what character exactly are in my identation if they arent whitespace, or tabs?

I'm asking this because I'm planning to ignore wh开发者_开发问答itespace in vimdiff, but isn't doing this going to be a problem when editing python files, where whitespace is relevant?


The indentation is spaces. Trailing whitespace is whitespace with nothing but a newline after it. Indentation obviously has code after it, thus no list char.

In regards to your edit, you have a few options.

  • Don't make vimdiff ignore whitespace for python files by setting diffopt with an autocmd FileType python.
  • Indent your code using tabs (set noexpandtab for python files), and use set list when diffing files to compare indentation. This is far less desirable because vim won't highlight and point out the differences in indentation for you.

There may be more options, but those are the two I can think of at the moment.


Look at a typical source file with a hex editor, or use Python:

python -c "print repr(open('yourfile.py', 'rb').read(1024))"

will print the first 1Kb of your file unambiguously.

0

精彩评论

暂无评论...
验证码 换一张
取 消