It seems quite tedious for me to remember how various settings are assigned, and so I find myself looking at :h or google or posting here to figure out how each setting is assigned (or just doing trial and error and using all possible combinations). For example, take the following two commands:

 autocmd BufNewFile,BufRead *.txt set filetype=markdown
 autocmd BufNewFile,BufRead *.txt colorscheme OceanicNext

Why is the first command using = for assignment and the second one doesn't use anything (other than a space). At least to me (though admittedly I'm very new to vim), it seems there isn't much rhyme or reason as to the consistency of assignment (for example, why not just use set [var]=[value] for everything?). Is there a way to help remember which is which, or it really just comes down to practice?

  1. Pressing K immediately shows help for the word under cursor (in fact, it execs :h 'keywordprg', but the standard ftplugin sets its value to :help for "vim" files).

  2. All :-commands have standardized structure: [range]command[!] [parameters]. Here set and colorscheme are commands, and so they both are followed by space. filetype=markdown is a parameter. Its format depends on the leading command (:set). If you don't remember it you should read :h :set.

  • thanks, could you please explain the K immediately thing? – David542 Jun 12 '20 at 6:29
  • Oh, I see. When in normal mode, and my cursor is above a term, I can press Shift-k (capital K) to view help for that word. – David542 Jun 12 '20 at 6:30
  • @David542 I mean it's Normal mode command, not Ex-command. – Matt Jun 12 '20 at 6:30

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.