关于vim使用,插入注释字符时(例如#)

2024-04-26 17:21:11 发布

您现在位置:Python中文网/ 问答频道 /正文

系统:ubuntu 14.04.2

我使用vim7.4编写python代码,有时我想插入一个“#”(注释),然后vim将这个“#”带到行的顶部。 也许我解释不清楚。 例子: 代码:

if 'test' == 'abc':
    print 'something'

我想在秒中插入一个“#”排队。然后呢发生这种情况:

if 'test' == 'abc':
#   print 'something'

这是自动发生的。你知道吗

但我想这样做:

if 'test' == 'abc':
    # print 'something'

Tags: 代码testifubuntu系统情况vimsomething
1条回答
网友
1楼 · 发布于 2024-04-26 17:21:11

哈希字符#http://vim.wikia.com/wiki/Restoring_indent_after_typing_hash的缩进有问题

Q: Why does Vim place # at the first column?

A: You are using 'smartindent', or you have 0# in your 'cinkeys' or 'indentkeys' options.

Under some circumstances, when you type a '#' character while in insert mode, the indent on the current line will be removed. Also, formatting or otherwise attempting to adjust the indent of a line starting with '#' may not work as you expect.

This tip discusses the issues and how problems can be avoided.

相关问题 更多 >