Hacker News new | past | comments | ask | show | jobs | submit login

Ugh. Be careful with that, since actually giving a /g has the effect of toggling the behaviour all together.

From :help 'gdefault':-

    :help 'gdefault'
    'gdefault' 'gd'		boolean	(default off)
    global
    {not in Vi}
    When on, the ":substitute" flag 'g' is default on.  This means that
    all matches in a line are substituted instead of one.  When a 'g' flag
    is given to a ":substitute" command, this will toggle the substitution
    of all or one match.  See |complex-change|.

    command		'gdefault' on	'gdefault' off	~
    :s///		  subst. all	  subst. one
    :s///g		  subst. one	  subst. all
    :s///gg		  subst. all	  subst. one
While not quite documented under ":help :s_flags", two 'g' flags cancel each other out. This also applies to 'gdefault'.

Also, be aware that this may break a huge amount of scripts out there, should you decide to use it as some (hard to debug) issues are caused because of it.




I've had this set for a while now and haven't noticed any scripts breaking. It's far more common for scripts to break because I'm remapped something and they used 'nmap' instead of 'nnoremap' or 'normal' instead of 'normal!'.

Whenever a script breaks, I bite the bullet and fix it, fork it on Github, switch my dotfiles repo to use my fork and send a pull request. If they merge my fix I switch my dotfiles repo back.

It's a pain in the ass, but I like to think that it helps other Vim users a little bit.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: