From: Michael Tremer <michael.tremer@ipfire.org>
To: development@lists.ipfire.org
Subject: Re: [PATCH] brutally tell ignorant Vim not to indent Python scripts with spaces
Date: Fri, 13 Nov 2020 14:09:02 +0000 [thread overview]
Message-ID: <A95B72C8-061E-4BE2-810E-5663FE8450A3@ipfire.org> (raw)
In-Reply-To: <f4f2d5e9-024e-3762-8aac-e15adbd07fa7@ipfire.org>
[-- Attachment #1: Type: text/plain, Size: 9842 bytes --]
Hi,
I hope you have calmed down by now. *Pushing over a glass of whisky*
I totally agree with this. I kind of get what they tried to achieve here but unfortunately that didn’t work. But I think other editors get their default configuration very very wrong too. Why do I need to enable basic features? I am looking at you - nano.
> On 11 Nov 2020, at 16:02, Peter Müller <peter.mueller(a)ipfire.org> wrote:
>
> This patch brutally overwrites the default vimrc file located at
> /usr/share/vim/vim81/defaults.vim (at the time of writing) in order to
> tell Vim it must not indent Python scripts with spaces.
>
> Since we have agreed on indenting Python scripts with tabs (the PEP8
> standard does not give a very plausible explanation why spaces are better
> than tabs, anyway - but hey, those are the experts [tm], and who are we
> to question their decisions?!), the auto-indention of Vim has been an
> ongoing nuisance:
>
> Instead of even trying to be smart and checking the indention type of
> the source code lines before, it just expands tabs to spaces by default,
> rendering Python scripts with tabulators as indention unusable as soon
> as any additional line is inserted. Ultimately, using nano as a quick
> workaround "solved" the problem, but makes developing a pain in the ass
> deluxe.
>
> Vim is probably the most arrogant and ignorant editor ever written. It
> is even worse than proprietary/commercial products such as IDEs by M$,
> and that's saying something.
Erm. Have you met Emacs?
> (I mean, if a user is pressing a certain key on his/her/its keyboard,
> who could have _thought_ of the possibility that this user actually _wanted_
> to consciously press this key and have its output on the screen.
> Assisted programming comes to mind; using computers as tools is one
> thing, letting them do the thinking is another... :-/ )
>
> Of course, one could disable expanding tabs into spaces by setting up a
> custom ~/.vimrc file, but this causes Vim to ignore _any_ other
> directives as well, which means there is no syntax highlighting anymore,
> matching brackets are not marked as such, and we are basically sitting
> in front of an machine behaving like one of its colleagues in the 80s.
>
> Some smart people came up with the idea of system-wide files such as
> /etc/ssh/ssh_config, or /etc/vim/vimrc, respectively. It even contains
> statements for including a _custom_ vimrc at /etc/vim/vimrc.local, which
> is exactly what we want to do.
>
> However, Vim reads its configuration from /usr/share/vim/vimrc, which is
> not simply a symlink to /etc/vim/vimrc or vice versa (that would be too
> easy, wouldn't it - why not spreading the same content twice across a
> system to bloat up things a little bit, eh?), and jumps into a
> Debian-specific configuration file afterwards.
>
> As soon as any custom directive is placed in /etc/vim/vimrc.local and
> Vim is told not to overwrite it, we are dealing with the same
> less-than-default configuration mentioned above.
>
> This leaves us with the decision of
> (a) either copying the entire content of /usr/share/vim/vim81/defaults.vim
> to _every_ users home directory, creating boiler plate configuration
> en masse or
> (b) tamper with files managed by the systems' packaging tool, which
> means we are damaging the integrity of our machines (did anyone
> mentioned security here?!), for nothing except a simple change to
> the Python indention plugin behaviour at all.
>
> In the authors opinion, (b) is the least unfavourable option. This patch finally
> "solves" the unwanted Vim behaviour on our machines, hopefully making
> Michaels and my lives a little bit less harassed, since we need to puke
> into one less front yard of another development team all the time.
I am looking for anything to get my blood pressure down these days…
Keep them coming, those fixes for the problems of my life.
-Michael
> Cc: Michael Tremer <michael.tremer(a)ipfire.org>
> Signed-off-by: Peter Müller <peter.mueller(a)ipfire.org>
> ---
> files/usr/share/vim/vim81/defaults.vim | 143 +++++++++++++++++++++++++
> 1 file changed, 143 insertions(+)
> create mode 100644 files/usr/share/vim/vim81/defaults.vim
>
> diff --git a/files/usr/share/vim/vim81/defaults.vim b/files/usr/share/vim/vim81/defaults.vim
> new file mode 100644
> index 0000000..100cf12
> --- /dev/null
> +++ b/files/usr/share/vim/vim81/defaults.vim
> @@ -0,0 +1,143 @@
> +" The default vimrc file.
> +"
> +" Maintainer: Bram Moolenaar <Bram(a)vim.org>
> +" Last change: 2019 Feb 18
> +"
> +" This is loaded if no vimrc file was found.
> +" Except when Vim is run with "-u NONE" or "-C".
> +" Individual settings can be reverted with ":set option&".
> +" Other commands can be reverted as mentioned below.
> +
> +" When started as "evim", evim.vim will already have done these settings.
> +if v:progname =~? "evim"
> + finish
> +endif
> +
> +" Bail out if something that ran earlier, e.g. a system wide vimrc, does not
> +" want Vim to use these default values.
> +if exists('skip_defaults_vim')
> + finish
> +endif
> +
> +" Use Vim settings, rather than Vi settings (much better!).
> +" This must be first, because it changes other options as a side effect.
> +" Avoid side effects when it was already reset.
> +if &compatible
> + set nocompatible
> +endif
> +
> +" When the +eval feature is missing, the set command above will be skipped.
> +" Use a trick to reset compatible only when the +eval feature is missing.
> +silent! while 0
> + set nocompatible
> +silent! endwhile
> +
> +" Allow backspacing over everything in insert mode.
> +set backspace=indent,eol,start
> +
> +set history=200 " keep 200 lines of command line history
> +set ruler " show the cursor position all the time
> +set showcmd " display incomplete commands
> +set wildmenu " display completion matches in a status line
> +
> +set ttimeout " time out for key codes
> +set ttimeoutlen=100 " wait up to 100ms after Esc for special key
> +
> +" Show @@@ in the last line if it is truncated.
> +set display=truncate
> +
> +" Show a few lines of context around the cursor. Note that this makes the
> +" text scroll if you mouse-click near the start or end of the window.
> +set scrolloff=5
> +
> +" Do incremental searching when it's possible to timeout.
> +if has('reltime')
> + set incsearch
> +endif
> +
> +" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
> +" confusing.
> +set nrformats-=octal
> +
> +" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
> +if has('win32')
> + set guioptions-=t
> +endif
> +
> +" Don't use Ex mode, use Q for formatting.
> +" Revert with ":unmap Q".
> +map Q gq
> +
> +" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
> +" so that you can undo CTRL-U after inserting a line break.
> +" Revert with ":iunmap <C-U>".
> +inoremap <C-U> <C-G>u<C-U>
> +
> +" In many terminal emulators the mouse works just fine. By enabling it you
> +" can position the cursor, Visually select and scroll with the mouse.
> +if has('mouse')
> + set mouse=a
> +endif
> +
> +" Switch syntax highlighting on when the terminal has colors or when using the
> +" GUI (which always has colors).
> +if &t_Co > 2 || has("gui_running")
> + " Revert with ":syntax off".
> + syntax on
> +
> + " I like highlighting strings inside C comments.
> + " Revert with ":unlet c_comment_strings".
> + let c_comment_strings=1
> +endif
> +
> +" Only do this part when Vim was compiled with the +eval feature.
> +if 1
> +
> + " Enable file type detection.
> + " Use the default filetype settings, so that mail gets 'tw' set to 72,
> + " 'cindent' is on in C files, etc.
> + " Also load indent files, to automatically do language-dependent indenting.
> + " Revert with ":filetype off".
> + filetype plugin indent on
> +
> + " Put these in an autocmd group, so that you can revert them with:
> + " ":augroup vimStartup | au! | augroup END"
> + augroup vimStartup
> + au!
> +
> + " When editing a file, always jump to the last known cursor position.
> + " Don't do it when the position is invalid, when inside an event handler
> + " (happens when dropping a file on gvim) and for a commit message (it's
> + " likely a different one than last time).
> + autocmd BufReadPost *
> + \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
> + \ | exe "normal! g`\""
> + \ | endif
> +
> + augroup END
> +
> +endif
> +
> +" Convenient command to see the difference between the current buffer and the
> +" file it was loaded from, thus the changes you made.
> +" Only define it when not defined already.
> +" Revert with: ":delcommand DiffOrig".
> +if !exists(":DiffOrig")
> + command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
> + \ | wincmd p | diffthis
> +endif
> +
> +if has('langmap') && exists('+langremap')
> + " Prevent that the langmap option applies to characters that result from a
> + " mapping. If set (default), this may break plugins (but it's backward
> + " compatible).
> + set nolangremap
> +endif
> +
> +" Tell vim not to indent Python scripts with spaces, without
> +" (a) forgetting anything else (happens if we use a custom .vimrc, but hey!)
> +" (b) overriding system-wide vimrc files such as /etc/vim/vimrc.local
> +" (those are _system-wide_, so why should an application care about it?!)
> +" (c) be too invasive when it comes to patch indention files for Python itself
> +autocmd FileType python setlocal expandtab! tabstop=8 shiftwidth=8 softtabstop=0
> +
> --
> 2.26.2
prev parent reply other threads:[~2020-11-13 14:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-11 16:02 Peter Müller
2020-11-13 14:09 ` Michael Tremer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A95B72C8-061E-4BE2-810E-5663FE8450A3@ipfire.org \
--to=michael.tremer@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox