{"id":305,"date":"2020-12-31T14:11:29","date_gmt":"2020-12-31T22:11:29","guid":{"rendered":"http:\/\/bornski.com\/maria\/blog\/?p=305"},"modified":"2022-11-21T13:54:04","modified_gmt":"2022-11-21T21:54:04","slug":"adventures-in-programming-why-is-vim-doing-that","status":"publish","type":"post","link":"https:\/\/bornski.com\/maria\/blog\/2020\/12\/31\/adventures-in-programming-why-is-vim-doing-that\/","title":{"rendered":"Adventures in programming: Why is vim doing that?"},"content":{"rendered":"\n<p>Often in programming, you set out to write some code and you end up on a wild tangent instead.  Seeing how someone else walks through one of their wild tangents can be very helpful, so here&#8217;s a walk through of the wild tangent I went on today.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What was I trying to do?<\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>I&#8217;m working on scanning a bunch of old family photos and I eventually plan to put them online.  Before I do so, I want to make sure the EXIF metadata is useful and well formatted, so I created myself a new github repo to store some scripts I&#8217;m planning to write.  As I was writing a commit message while adding my initial <code>.gitignore<\/code>, I noticed that vim was inserting newlines and wrapping my commit message without me hitting Enter to move to a new line.  While I certainly love a well formatted commit message, it really pulls me out of any kind of flow to have my text editor moving me to a new line without my asking.  This annoys me enough, that I decided to dig into vim and figure out why my text was auto wrapping.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why is vim automatically wrapping text?<\/h2>\n\n\n\n<hr class=\"wp-block-separator is-style-default\"\/>\n\n\n\n<!--more-->\n\n\n\n<p>First up, googling to remind myself what setting control text wrapping.   My googling led me to <a href=\"https:\/\/vi.stackexchange.com\/questions\/2784\/how-to-stop-gvim-wrapping-text-at-column-80\">https:\/\/vi.stackexchange.com\/questions\/2784\/how-to-stop-gvim-wrapping-text-at-column-80<\/a>  Based on that page, I want to check <code>textwidth<\/code> and <code>formatoptions<\/code> by running the following from within vim:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Check textwidth value\n:set tw?\n# Check formatoptions value\n:set fo?<\/code><\/pre>\n\n\n\n<p>I opened back up my <code>.gitignore<\/code> in vim and looked at those values:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:set tw?\n  textwidth=0  \n:set fo?\n  formatoptions=croql\n<\/code><\/pre>\n\n\n\n<p>Hmmm, that <code>textwidth=0<\/code> should mean that vim doesn&#8217;t auto wrap, but it definitely did auto wrap.  I ran this from Windows Subsystem for Linux (WSL), which I&#8217;m new to using, so I decided to compare against what git bash sees.  I fired up a git bash terminal, ran <code>vim empty.txt<\/code> at the command line, then re-ran those commands within vim: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:set tw?\n  textwidth=0  \n:set fo?\n  formatoptions=tcq\n<\/code><\/pre>\n\n\n\n<p>Well, that also shouldn&#8217;t wrap, but doesn&#8217;t match what I saw when I opened<code> .gitignore<\/code>!  My work Mac doesn&#8217;t do this, what&#8217;s different there?  Checking again from <code>vim empty.txt<\/code>, but from my work Mac:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:set tw?\n  textwidth=0  \n:set fo?\n  formatoptions=tcq\n<\/code><\/pre>\n\n\n\n<p>Huh, that setting is the same.  Ah, but wait!  I had seen the wrapping during writing a commit message.  I fired up a quick commit  message with <code>git commit --allow-empty<\/code> from WSL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:set tw?\n  textwidth=72\n:set fo?\n  formatoptions=tl<\/code><\/pre>\n\n\n\n<p>Aha!  Text wrapping is turned on, but why?  Is it turned on in git bash? <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:set tw?\n  textwidth=72\n:set fo?\n  formatoptions=tl<\/code><\/pre>\n\n\n\n<p>Yup, also on there!  What about my work Mac?<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:set tw?\n  textwidth=0  \n:set fo?\n  formatoptions=tcq\n<\/code><\/pre>\n\n\n\n<p>Aha, text wrapping is NOT turned on for my work Mac when I write a commit message.  <\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>So, automatic wrapping is showing up for me on Windows when I write a git commit message, regardless of whether I&#8217;m using WSL or git bash.  It is not showing up for me on my work Mac.  <\/p>\n\n\n\n<p>What is turning this automatic text wrapping on?  Googling &#8220;what sets vim formatoptions git commit message&#8221; leads me to <a href=\"https:\/\/stackoverflow.com\/questions\/3459744\/vim-using-non-standard-configuration-when-called-from-git-commit\">https:\/\/stackoverflow.com\/questions\/3459744\/vim-using-non-standard-configuration-when-called-from-git-commit<\/a> which mentions this might be caused by the filetype plugin.  It turns out I can check my filetype plugin settings by running the following from within vim:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Check filetype settings\n:filetype<\/code><\/pre>\n\n\n\n<p>To be super sure I&#8217;m looking at the right settings, I ran this from within a git commit message again.<\/p>\n\n\n\n<p>WSL and git bash:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:filetype\nfiletype detection:ON &nbsp;plugin:ON &nbsp;indent:ON<\/code><\/pre>\n\n\n\n<p>Mac:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:filetype\nfiletype detection:ON &nbsp;plugin:OFF &nbsp;indent:OFF<\/code><\/pre>\n\n\n\n<p>Well look at that!  The filetype plugin is turned on in my Windows setup and turned off in my Mac setup!  It looks like I&#8217;ve found the culprit!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Now how do I turn off this automatic text wrapping?<\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Now to chase down why these settings are different so I can figure out how best to turn off the filetype plugin &#8212; Time to look at what version(s) of vim I&#8217;m using and what&#8217;s in my vimrc files.<\/p>\n\n\n\n<p>WSL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>maria@personal-laptop:\/mnt\/c\/Users\/maria\/programming\/image-processing-helpers$ vim --version\nVIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 15 2020 06:40:31)\nIncluded patches: 1-2269\nModified by team+vim@tracker.debian.org\nCompiled by team+vim@tracker.debian.org\nHuge version without GUI.&nbsp; Features included (+) or not (-):\n+acl &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -farsi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -mouse_sysmouse &nbsp; &nbsp;-tag_any_white\n+arabic &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+file_in_path &nbsp; &nbsp; &nbsp;+mouse_urxvt &nbsp; &nbsp; &nbsp; -tcl\n+autocmd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +find_in_path &nbsp; &nbsp; &nbsp;+mouse_xterm &nbsp; &nbsp; &nbsp; +termguicolors\n+autochdir &nbsp; &nbsp; &nbsp; &nbsp; +float &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +multi_byte &nbsp; &nbsp; &nbsp; &nbsp;+terminal\n-autoservername &nbsp; &nbsp;+folding &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +multi_lang &nbsp; &nbsp; &nbsp; &nbsp;+terminfo\n-balloon_eval &nbsp; &nbsp; &nbsp;-footer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-mzscheme &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+termresponse\n+balloon_eval_term +fork() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+netbeans_intg &nbsp; &nbsp; +textobjects\n-browse &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+gettext &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +num64 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +textprop\n++builtin_terms &nbsp; &nbsp;-hangul_input &nbsp; &nbsp; &nbsp;+packages &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+timers\n+byte_offset &nbsp; &nbsp; &nbsp; +iconv &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +path_extra &nbsp; &nbsp; &nbsp; &nbsp;+title\n+channel &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +insert_expand &nbsp; &nbsp; -perl &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-toolbar\n+cindent &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +job &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +persistent_undo &nbsp; +user_commands\n-clientserver &nbsp; &nbsp; &nbsp;+jumplist &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+postscript &nbsp; &nbsp; &nbsp; &nbsp;+vartabs\n-clipboard &nbsp; &nbsp; &nbsp; &nbsp; +keymap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+printer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +vertsplit\n+cmdline_compl &nbsp; &nbsp; +lambda &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+profile &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +virtualedit\n+cmdline_hist &nbsp; &nbsp; &nbsp;+langmap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -python &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+visual\n+cmdline_info &nbsp; &nbsp; &nbsp;+libcall &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +python3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +visualextra\n+comments &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+linebreak &nbsp; &nbsp; &nbsp; &nbsp; +quickfix &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+viminfo\n+conceal &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +lispindent &nbsp; &nbsp; &nbsp; &nbsp;+reltime &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +vreplace\n+cryptv &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+listcmds &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+rightleft &nbsp; &nbsp; &nbsp; &nbsp; +wildignore\n+cscope &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+localmap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-ruby &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+wildmenu\n+cursorbind &nbsp; &nbsp; &nbsp; &nbsp;-lua &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +scrollbind &nbsp; &nbsp; &nbsp; &nbsp;+windows\n+cursorshape &nbsp; &nbsp; &nbsp; +menu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+signs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +writebackup\n+dialog_con &nbsp; &nbsp; &nbsp; &nbsp;+mksession &nbsp; &nbsp; &nbsp; &nbsp; +smartindent &nbsp; &nbsp; &nbsp; -X11\n+diff &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+modify_fname &nbsp; &nbsp; &nbsp;+sound &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -xfontset\n+digraphs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+mouse &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +spell &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -xim\n-dnd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -mouseshape &nbsp; &nbsp; &nbsp; &nbsp;+startuptime &nbsp; &nbsp; &nbsp; -xpm\n-ebcdic &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+mouse_dec &nbsp; &nbsp; &nbsp; &nbsp; +statusline &nbsp; &nbsp; &nbsp; &nbsp;-xsmp\n+emacs_tags &nbsp; &nbsp; &nbsp; &nbsp;+mouse_gpm &nbsp; &nbsp; &nbsp; &nbsp; -sun_workshop &nbsp; &nbsp; &nbsp;-xterm_clipboard\n+eval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-mouse_jsbterm &nbsp; &nbsp; +syntax &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-xterm_save\n+ex_extra &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+mouse_netterm &nbsp; &nbsp; +tag_binary\n+extra_search &nbsp; &nbsp; &nbsp;+mouse_sgr &nbsp; &nbsp; &nbsp; &nbsp; -tag_old_static\n&nbsp; &nbsp;system vimrc file: \"$VIM\/vimrc\"\n&nbsp; &nbsp; &nbsp;user vimrc file: \"$HOME\/.vimrc\"\n&nbsp;2nd user vimrc file: \"~\/.vim\/vimrc\"\n&nbsp; &nbsp; &nbsp; user exrc file: \"$HOME\/.exrc\"\n&nbsp; &nbsp; &nbsp; &nbsp;defaults file: \"$VIMRUNTIME\/defaults.vim\"\n&nbsp; fall-back for $VIM: \"\/usr\/share\/vim\"\nCompilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H &nbsp; -Wdate-time &nbsp;-g -O2 -fdebug-prefix-map=\/build\/vim-iU6mZD\/vim-8.1.2269=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1\nLinking: gcc &nbsp; -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim &nbsp; &nbsp; &nbsp; &nbsp;-lm -ltinfo -lnsl &nbsp;-lselinux &nbsp;-lcanberra -lacl -lattr -lgpm -ldl &nbsp; &nbsp; -L\/usr\/lib\/python3.8\/config-3.8-x86_64-linux-gnu -lpython3.8 -lcrypt -lpthread -ldl -lutil -lm -lm\nmaria@LAPTOP-TNGCNLQI:\/mnt\/c\/Users\/maria\/programming\/image-processing-helpers$ cat ~\/.vimrc\ncat: \/home\/maria\/.vimrc: No such file or directory<\/code><\/pre>\n\n\n\n<p>git bash:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>maria@personal-laptop MINGW64 ~\/programming\/tic-tac-toe (master)\n$ vim --version\nVIM - Vi IMproved 8.1 (2018 May 18, compiled Feb &nbsp;7 2019 12:09:30)\nIncluded patches: 1-877\nCompiled by &lt;alexpux@gmail.com&gt;\nHuge version without GUI.&nbsp; Features included (+) or not (-):\n+acl &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +extra_search &nbsp; &nbsp; &nbsp;+mouse_netterm &nbsp; &nbsp; +tag_old_static\n+arabic &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+farsi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +mouse_sgr &nbsp; &nbsp; &nbsp; &nbsp; -tag_any_white\n+autocmd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +file_in_path &nbsp; &nbsp; &nbsp;-mouse_sysmouse &nbsp; &nbsp;-tcl\n+autochdir &nbsp; &nbsp; &nbsp; &nbsp; +find_in_path &nbsp; &nbsp; &nbsp;+mouse_urxvt &nbsp; &nbsp; &nbsp; +termguicolors\n-autoservername &nbsp; &nbsp;+float &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +mouse_xterm &nbsp; &nbsp; &nbsp; +terminal\n-balloon_eval &nbsp; &nbsp; &nbsp;+folding &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +multi_byte &nbsp; &nbsp; &nbsp; &nbsp;+terminfo\n+balloon_eval_term -footer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+multi_lang &nbsp; &nbsp; &nbsp; &nbsp;+termresponse\n-browse &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+fork() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-mzscheme &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+textobjects\n++builtin_terms &nbsp; &nbsp;+gettext &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +netbeans_intg &nbsp; &nbsp; +textprop\n+byte_offset &nbsp; &nbsp; &nbsp; -hangul_input &nbsp; &nbsp; &nbsp;+num64 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +timers\n+channel &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +iconv &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +packages &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+title\n+cindent &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +insert_expand &nbsp; &nbsp; +path_extra &nbsp; &nbsp; &nbsp; &nbsp;-toolbar\n-clientserver &nbsp; &nbsp; &nbsp;+job &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +perl\/dyn &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+user_commands\n+clipboard &nbsp; &nbsp; &nbsp; &nbsp; +jumplist &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+persistent_undo &nbsp; +vartabs\n+cmdline_compl &nbsp; &nbsp; +keymap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+postscript &nbsp; &nbsp; &nbsp; &nbsp;+vertsplit\n+cmdline_hist &nbsp; &nbsp; &nbsp;+lambda &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+printer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +virtualedit\n+cmdline_info &nbsp; &nbsp; &nbsp;+langmap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +profile &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +visual\n+comments &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+libcall &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +python\/dyn &nbsp; &nbsp; &nbsp; &nbsp;+visualextra\n+conceal &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +linebreak &nbsp; &nbsp; &nbsp; &nbsp; +python3\/dyn &nbsp; &nbsp; &nbsp; +viminfo\n+cryptv &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+lispindent &nbsp; &nbsp; &nbsp; &nbsp;+quickfix &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+vreplace\n+cscope &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+listcmds &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+reltime &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +wildignore\n+cursorbind &nbsp; &nbsp; &nbsp; &nbsp;+localmap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+rightleft &nbsp; &nbsp; &nbsp; &nbsp; +wildmenu\n+cursorshape &nbsp; &nbsp; &nbsp; -lua &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +ruby\/dyn &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+windows\n+dialog_con &nbsp; &nbsp; &nbsp; &nbsp;+menu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+scrollbind &nbsp; &nbsp; &nbsp; &nbsp;+writebackup\n+diff &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+mksession &nbsp; &nbsp; &nbsp; &nbsp; +signs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -X11\n+digraphs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+modify_fname &nbsp; &nbsp; &nbsp;+smartindent &nbsp; &nbsp; &nbsp; -xfontset\n-dnd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +mouse &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +startuptime &nbsp; &nbsp; &nbsp; -xim\n-ebcdic &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-mouseshape &nbsp; &nbsp; &nbsp; &nbsp;+statusline &nbsp; &nbsp; &nbsp; &nbsp;-xpm\n+emacs_tags &nbsp; &nbsp; &nbsp; &nbsp;+mouse_dec &nbsp; &nbsp; &nbsp; &nbsp; -sun_workshop &nbsp; &nbsp; &nbsp;-xsmp\n+eval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-mouse_gpm &nbsp; &nbsp; &nbsp; &nbsp; +syntax &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-xterm_clipboard\n+ex_extra &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-mouse_jsbterm &nbsp; &nbsp; +tag_binary &nbsp; &nbsp; &nbsp; &nbsp;-xterm_save\n&nbsp; &nbsp;system vimrc file: \"\/etc\/vimrc\"\n&nbsp; &nbsp; &nbsp;user vimrc file: \"$HOME\/.vimrc\"\n&nbsp;2nd user vimrc file: \"~\/.vim\/vimrc\"\n&nbsp; &nbsp; &nbsp; user exrc file: \"$HOME\/.exrc\"\n&nbsp; &nbsp; &nbsp; &nbsp;defaults file: \"$VIMRUNTIME\/defaults.vim\"\n&nbsp; fall-back for $VIM: \"\/etc\"\n&nbsp;f-b for $VIMRUNTIME: \"\/usr\/share\/vim\/vim81\"\nCompilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H &nbsp; -I\/usr\/include\/ncursesw &nbsp;-march=x86-64 -mtune=generic -O2 -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1\nLinking: gcc &nbsp; -L. -pipe -fstack-protector-strong -pipe -Wl,--as-needed -o vim.exe &nbsp; &nbsp; &nbsp; &nbsp;-lm -lelf &nbsp; &nbsp;-lncursesw -liconv -lacl -lintl &nbsp; -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong &nbsp;-L\/usr\/lib\/perl5\/core_perl\/CORE -lperl -lpthread -ldl -lcrypt\n\nmaria@personal-laptop MINGW64 ~\/programming\/tic-tac-toe (master)\n$ cat ~\/.vimrc\ncat: \/c\/Users\/maria\/.vimrc: No such file or directory<\/code><\/pre>\n\n\n\n<p>Mac:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;maria@work-laptop:~]$ vim --version\nVIM - Vi IMproved 8.1 (2018 May 18, compiled Jun &nbsp;5 2020 21:30:37)\nmacOS version\nIncluded patches: 1-503, 505-680, 682-2292\nCompiled by root@apple.com\nNormal version without GUI.&nbsp; Features included (+) or not (-):\n+acl &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -farsi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -mouse_sysmouse &nbsp; &nbsp;-tag_any_white\n-arabic &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+file_in_path &nbsp; &nbsp; &nbsp;-mouse_urxvt &nbsp; &nbsp; &nbsp; -tcl\n+autocmd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +find_in_path &nbsp; &nbsp; &nbsp;+mouse_xterm &nbsp; &nbsp; &nbsp; -termguicolors\n+autochdir &nbsp; &nbsp; &nbsp; &nbsp; +float &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +multi_byte &nbsp; &nbsp; &nbsp; &nbsp;+terminal\n-autoservername &nbsp; &nbsp;+folding &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +multi_lang &nbsp; &nbsp; &nbsp; &nbsp;+terminfo\n-balloon_eval &nbsp; &nbsp; &nbsp;-footer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-mzscheme &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+termresponse\n-balloon_eval_term +fork() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+netbeans_intg &nbsp; &nbsp; +textobjects\n-browse &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-gettext &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +num64 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +textprop\n+builtin_terms &nbsp; &nbsp; -hangul_input &nbsp; &nbsp; &nbsp;+packages &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+timers\n+byte_offset &nbsp; &nbsp; &nbsp; +iconv &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +path_extra &nbsp; &nbsp; &nbsp; &nbsp;+title\n+channel &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +insert_expand &nbsp; &nbsp; -perl &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-toolbar\n+cindent &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +job &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +persistent_undo &nbsp; +user_commands\n-clientserver &nbsp; &nbsp; &nbsp;+jumplist &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+postscript &nbsp; &nbsp; &nbsp; &nbsp;-vartabs\n+clipboard &nbsp; &nbsp; &nbsp; &nbsp; -keymap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+printer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +vertsplit\n+cmdline_compl &nbsp; &nbsp; +lambda &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-profile &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +virtualedit\n+cmdline_hist &nbsp; &nbsp; &nbsp;-langmap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +python\/dyn &nbsp; &nbsp; &nbsp; &nbsp;+visual\n+cmdline_info &nbsp; &nbsp; &nbsp;+libcall &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -python3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +visualextra\n+comments &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+linebreak &nbsp; &nbsp; &nbsp; &nbsp; +quickfix &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+viminfo\n-conceal &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +lispindent &nbsp; &nbsp; &nbsp; &nbsp;+reltime &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +vreplace\n+cryptv &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+listcmds &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-rightleft &nbsp; &nbsp; &nbsp; &nbsp; +wildignore\n+cscope &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+localmap &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ruby\/dyn &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+wildmenu\n+cursorbind &nbsp; &nbsp; &nbsp; &nbsp;-lua &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +scrollbind &nbsp; &nbsp; &nbsp; &nbsp;+windows\n+cursorshape &nbsp; &nbsp; &nbsp; +menu &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+signs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +writebackup\n+dialog_con &nbsp; &nbsp; &nbsp; &nbsp;+mksession &nbsp; &nbsp; &nbsp; &nbsp; +smartindent &nbsp; &nbsp; &nbsp; -X11\n+diff &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+modify_fname &nbsp; &nbsp; &nbsp;-sound &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -xfontset\n+digraphs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+mouse &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +spell &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -xim\n-dnd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -mouseshape &nbsp; &nbsp; &nbsp; &nbsp;+startuptime &nbsp; &nbsp; &nbsp; -xpm\n-ebcdic &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-mouse_dec &nbsp; &nbsp; &nbsp; &nbsp; +statusline &nbsp; &nbsp; &nbsp; &nbsp;-xsmp\n-emacs_tags &nbsp; &nbsp; &nbsp; &nbsp;-mouse_gpm &nbsp; &nbsp; &nbsp; &nbsp; -sun_workshop &nbsp; &nbsp; &nbsp;-xterm_clipboard\n+eval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-mouse_jsbterm &nbsp; &nbsp; +syntax &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-xterm_save\n+ex_extra &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-mouse_netterm &nbsp; &nbsp; +tag_binary &nbsp; &nbsp; &nbsp; &nbsp;\n+extra_search &nbsp; &nbsp; &nbsp;+mouse_sgr &nbsp; &nbsp; &nbsp; &nbsp; -tag_old_static &nbsp; &nbsp;\n&nbsp; &nbsp;system vimrc file: \"$VIM\/vimrc\"\n&nbsp; &nbsp; &nbsp;user vimrc file: \"$HOME\/.vimrc\"\n&nbsp;2nd user vimrc file: \"~\/.vim\/vimrc\"\n&nbsp; &nbsp; &nbsp; user exrc file: \"$HOME\/.exrc\"\n&nbsp; &nbsp; &nbsp; &nbsp;defaults file: \"$VIMRUNTIME\/defaults.vim\"\n&nbsp; fall-back for $VIM: \"\/usr\/share\/vim\"\nCompilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H &nbsp; -DMACOS_X_UNIX &nbsp;-g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 &nbsp; &nbsp; &nbsp;\nLinking: gcc &nbsp; -L\/usr\/local\/lib -o vim &nbsp; &nbsp; &nbsp; &nbsp;-lm -lncurses &nbsp;-liconv -framework Cocoa &nbsp;\n&#91;maria@work-laptop:~]$ cat ~\/.vimrc\nset expandtab\nset tabstop=4\nset ruler\nsyntax on\nif has('autocmd')\n    filetype on\n    if !exists(\"autocommands_loaded\")\n        let autocommands_loaded = 1\n        autocmd FileType go setlocal noexpandtab\n    endif\nendif<\/code><\/pre>\n\n\n\n<p>Hmmm, all 3 setups are using vim 8.1 though compiled at different times in different ways.  A noteable difference is that I have created a <code>~\/.vimrc<\/code> file on my work laptop but not on my personal laptop.  <\/p>\n\n\n\n<p>This leads to my next question &#8212; If I don&#8217;t have a <code>~\/.vimrc<\/code> file, what configuration files does vim use?  According to <a href=\"https:\/\/stackoverflow.com\/questions\/42772115\/bash-on-windows-10-where-is-vimrc\">https:\/\/stackoverflow.com\/questions\/42772115\/bash-on-windows-10-where-is-vimrc<\/a>, we can use <code>vim --version | grep vimrc<\/code> to find out.   I already ran <code>vim --version<\/code>, so I know that my interesting files are:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   system vimrc file: \"$VIM\/vimrc\"\n     user vimrc file: \"$HOME\/.vimrc\"\n 2nd user vimrc file: \"~\/.vim\/vimrc\"<\/code><\/pre>\n\n\n\n<p>Also of note is this line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  fall-back for $VIM: \"\/usr\/share\/vim\"\n<\/code><\/pre>\n\n\n\n<p>Adding that information together, I want to go look at <code>\/usr\/share\/vim\/vimrc<\/code> and compare between systems. Checking on WSL first:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>maria@personal-laptop:\/mnt\/c\/Users\/maria\/programming\/image-processing-helpers$ cat \/usr\/share\/vim\/vimrc\n\" All system-wide defaults are set in $VIMRUNTIME\/debian.vim and sourced by\n\" the call to :runtime you can find below.&nbsp; If you wish to change any of those\n\" settings, you should do it in this file (\/etc\/vim\/vimrc), since debian.vim\n\" will be overwritten everytime an upgrade of the vim packages is performed.\n\" It is recommended to make changes after sourcing debian.vim since it alters\n\" the value of the 'compatible' option.\n\nruntime! debian.vim\n\n\" Vim will load $VIMRUNTIME\/defaults.vim if the user does not have a vimrc.\n\" This happens after \/etc\/vim\/vimrc(.local) are loaded, so it will override\n\" any settings in these files.\n\" If you don't want that to happen, uncomment the below line to prevent\n\" defaults.vim from being loaded.\n\" let g:skip_defaults_vim = 1\n\n\" Uncomment the next line to make Vim more Vi-compatible\n\" NOTE: debian.vim sets 'nocompatible'.&nbsp; Setting 'compatible' changes numerous\n\" options, so any other options should be set AFTER setting 'compatible'.\n\"set compatible\n\n\" Vim5 and later versions support syntax highlighting. Uncommenting the next\n\" line enables syntax highlighting by default.\nif has(\"syntax\")\n&nbsp; syntax on\nendif\n\n\" If using a dark background within the editing area and syntax highlighting\n\" turn on this option as well\n\"set background=dark\n\n\" Uncomment the following to have Vim jump to the last position when\n\" reopening a file\n\"au BufReadPost * if line(\"'\\\"\") &gt; 1 &amp;&amp; line(\"'\\\"\") &lt;= line(\"$\") | exe \"normal! g'\\\"\" | endif\n\n\" Uncomment the following to have Vim load indentation rules and plugins\n\" according to the detected filetype.\n\"filetype plugin indent on\n\n\" The following are commented out as they cause vim to behave a lot\n\" differently from regular Vi. They are highly recommended though.\n\"set showcmd &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\" Show (partial) command in status line.\n\"set showmatch &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\" Show matching brackets.\n\"set ignorecase &nbsp; &nbsp; &nbsp; &nbsp; \" Do case insensitive matching\n\"set smartcase &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\" Do smart case matching\n\"set incsearch &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\" Incremental search\n\"set autowrite &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\" Automatically save before commands like :next and :make\n\"set hidden &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \" Hide buffers when they are abandoned\n\"set mouse=a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\" Enable mouse usage (all modes)\n\n\" Source a global configuration file if available\nif filereadable(\"\/etc\/vim\/vimrc.local\")\n&nbsp; source \/etc\/vim\/vimrc.local\nendif<\/code><\/pre>\n\n\n\n<p>Hmmmm, this section looks like it might be relevant:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\" Vim will load $VIMRUNTIME\/defaults.vim if the user does not have a vimrc.\n\" This happens after \/etc\/vim\/vimrc(.local) are loaded, so it will override\n\" any settings in these files.\n\" If you don't want that to happen, uncomment the below line to prevent\n\" defaults.vim from being loaded.\n\" let g:skip_defaults_vim = 1<\/code><\/pre>\n\n\n\n<p>What does the same file look like on my work Mac:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;maria@work-laptop:~]$ cat \/usr\/share\/vim\/vimrc \n\" Configuration file for vim\nset modelines=0\t\t\" CVE-2007-2438\n\n\" Normally we use vim-extensions. If you want true vi-compatibility\n\" remove change the following statements\nset nocompatible\t\" Use Vim defaults instead of 100% vi compatibility\nset backspace=2\t\t\" more powerful backspacing\n\n\" Don't write backup file if vim is being called by \"crontab -e\"\nau BufWrite \/private\/tmp\/crontab.* set nowritebackup nobackup\n\" Don't write backup file if vim is being called by \"chpass\"\nau BufWrite \/private\/etc\/pw.* set nowritebackup nobackup\n\nlet skip_defaults_vim=1<\/code><\/pre>\n\n\n\n<p>Aha, the file is different on my Mac &#8212; it is set to skip importing <code>defaults.vim<\/code> even if there is no <code>~\/.vimrc<\/code> file.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Since I know I don&#8217;t have a <code>~\/.vimrc<\/code> file on this Windows setup and my Mac setup both has a<code> ~\/.vimrc<\/code> file and skips importing <code>defaults.vim<\/code>, I&#8217;ll try adding a <code>~\/.vimrc<\/code> file on my Window setup &#8212; this should cause vim to stop importing <code>defaults.vim<\/code> and should turn off the filetype plugin for me.  I&#8217;ll go ahead and use the same <code>~\/.vimrc<\/code> contents from my work Mac, so my new <code>~\/.vimrc<\/code> is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>maria@personal-laptop:\/mnt\/c\/Users\/maria\/programming\/image-processing-helpers$ cat ~\/.vimrc\nset expandtab\nset tabstop=4\nset ruler\nsyntax on\nif has('autocmd')\n    filetype on\n    if !exists(\"autocommands_loaded\")\n        let autocommands_loaded = 1\n        autocmd FileType go setlocal noexpandtab\n    endif\nendif<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Success!<\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Did that fix the problem?  I check by again opening vim with <code>git commit --allow-empty<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:filetype\nfiletype detection:ON  plugin:OFF  indent:OFF\n:set tw?\n  textwidth=0  \n:set fo?\n  formatoptions=tcq\n<\/code><\/pre>\n\n\n\n<p>Hooray!  I turned off text wrapping!  And it only took like an hour to figure out!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final notes<\/h2>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Yes, programming is often like this.  I didn&#8217;t actually write any code today, but I did get my configuration updated to better suit my preferences and I got a blog post out of it. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Often in programming, you set out to write some code and you end up on a wild tangent instead. Seeing how someone else walks through one of their wild tangents can be very helpful, so here&#8217;s a walk through of the wild tangent I went on today. What was I trying to do? I&#8217;m working &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/bornski.com\/maria\/blog\/2020\/12\/31\/adventures-in-programming-why-is-vim-doing-that\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Adventures in programming: Why is vim doing that?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[28],"tags":[34,37,29,35,38,36],"_links":{"self":[{"href":"https:\/\/bornski.com\/maria\/blog\/wp-json\/wp\/v2\/posts\/305"}],"collection":[{"href":"https:\/\/bornski.com\/maria\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bornski.com\/maria\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bornski.com\/maria\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bornski.com\/maria\/blog\/wp-json\/wp\/v2\/comments?post=305"}],"version-history":[{"count":8,"href":"https:\/\/bornski.com\/maria\/blog\/wp-json\/wp\/v2\/posts\/305\/revisions"}],"predecessor-version":[{"id":314,"href":"https:\/\/bornski.com\/maria\/blog\/wp-json\/wp\/v2\/posts\/305\/revisions\/314"}],"wp:attachment":[{"href":"https:\/\/bornski.com\/maria\/blog\/wp-json\/wp\/v2\/media?parent=305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bornski.com\/maria\/blog\/wp-json\/wp\/v2\/categories?post=305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bornski.com\/maria\/blog\/wp-json\/wp\/v2\/tags?post=305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}