1

I'm not expert in vim at all but I like it a lot.

In my personal computer I've loaded the example_vimrc in my .vimrc and added some extra lines (which are not affecting the behavior depicted here) so when I type a bullet point and keep typing till 80 characters, vim automatically wraps my line an continues below like this

* This is an example line, just guess that the line break is at 80
  characters and when I keep typing vim do this great thing of
  indenting my lines like this.

In my job computer, I have the SAME .vimrc file but I managed to note that the condition 'if has ("autocmd")' is not true and I don't know what happens (because I'm newbie) but when I type the kind of text like above I get the following

* This is an example of a line representing what happens in my job
* I'm not really pressing ENTER, and obviously I'm not typing a 
* bullet like '*' with each new line because this is the same note 
* but vim automatically adds a new '*' with each line wrap

How can I get rid of this behavior?? I already read a related post and tried to use the option 'set comments=' but I get the following behavior

* This is a line after setting 'set comments=' which removes the '*'
I think, but after line wrapping the indentation doesn't work and
the text keeps appearing like this, although if I manually add blank
  spaces like in THIS LINE and I keep typing then when vim wraps the
  line, automatically aligns the text like this, I hope it can give 
  you a clue of what is happening.

Thanks in advance for your help!, remember my .vimrc is the example_vimrc

2

Check out Disable automatic comment insertion, you probably want to add this in your vimrc file:

:set formatoptions-=cro

From :h 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.

Edit: Looks like you were on the right track, I should have dug in the :set comments? direction.

The default value is s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- (and for the record you replaced mb:* with fb:*).

Read :h format-comments for more details:

The 'comments' option is a comma-separated list of parts. Each part defines a
type of comment string. A part consists of:
        {flags}:{string}

{string} is the literal text that must appear.

{flags}:

  m     Middle of a three-piece comment

  f     Only the first line has the comment string.  Do not repeat comment on
        the next line, but preserve indentation (e.g., a bullet-list).
  • I tried it but nothing changed, as your reply states 'The default setting is tcq' I had default values and if I do ':set fo-=cro' nothing changes because the value is actually 'tcq' (not containing cro), thanks anyway. – Migdress Aug 29 '17 at 18:13
  • Maybe test with vim -u NONE and compare the vim --version on both machines (then edit your question). I wonder which &filetype is this? – LEI Aug 29 '17 at 18:18
  • vim version in my job machine is 7.4.52 and if I do :set filetype? when executed vim -u NONE the result is filetype= – Migdress Aug 29 '17 at 18:21
  • Hey! I just discovered something, if I type '-' instead of '*' the behavior is the expected!! hope this helps – Migdress Aug 29 '17 at 18:33
  • Glad you found out, happy vimming ;) – LEI Aug 29 '17 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.