Я могу отключить продолжение комментариев к следующей строке в Vim?

В Vim, если я ввожу комментарий в файле кода, и я совершил нападки, Входят, он автоматически делает новую строку комментарием, также.

Например, в файле Ruby:

# I manually typed the pound at the start of this line and hit enter.
# This line formatted itself this way automatically.

Обычно это - то, что я хочу, но не всегда. Как я могу временно выключить это поведение автокомментария?

66
задан 06.07.2018, 00:25

2 ответа

Я думаю, что Вы ищете

:set formatoptions-=cro

От :help fo-table:

You can use the 'formatoptions' option  to influence how Vim formats text.
'formatoptions' is a string that can contain any of the letters below.  The
default setting is "tcq".  You can separate the option letters with commas for
readability.

letter  meaning when present in 'formatoptions'

t       Auto-wrap text using textwidth
c       Auto-wrap comments using textwidth, inserting the current comment
        leader automatically.
r       Automatically insert the current comment leader after hitting
        <Enter> in Insert mode.
o       Automatically insert the current comment leader after hitting 'o' or
        'O' in Normal mode.
...
86
ответ дан 07.12.2019, 08:14

Установка Temporarily опция 'вставки' может сделать то, что Вы хотите, но она также отключает много других опций Vim:

Использовать :set paste включать его и :set nopaste выключить его. С другой стороны, можно использовать :set paste! переключить это.

См. также:

:help 'paste'
:help 'pastetoggle'

(Те команды вводятся с одинарными кавычками.)

9
ответ дан 07.12.2019, 08:14

Теги

Похожие вопросы