| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a tidier method of preserving the cursor position after a
normal-mode join that doesn't involve wiping away a mark, though I don't
use those too often anyway.
It still works with a preceding count via the `v:count1` variable, with
an accidental feature: this joins the *next* v:count1 lines, as opposed
to joining a *total* of v:count1 lines counting the current one. The
latter is what Vim does, but the former is what I'd actually expect,
thinking of it as a "repeated operation", so I'm going to leave it this
way.
|
|
|
|
| |
Just for clarity of reading.
|
|
|
|
| |
Just to do one thing at a time.
|
|
|
|
| |
It's probably best not to use abbreviations in scripts.
|
|
|
|
|
| |
On looking at this again, I was uncomfortable with `eval`ing an
operation. This seems a bit less evil.
|
|
|
|
|
|
|
|
| |
Per Google's VimScript style recommendations
<https://google.github.io/styleguide/vimscriptguide.xml>:
> Always use case-explicit operators for strings (=~# and =~?, never
> =~).
|
|
|
|
|
| |
The actual option settings performed by the function are local, so the
test should be, too.
|
|
|
|
| |
Just to avoid duplication a little; seems a little clearer this way.
|
|
|
|
|
| |
Essentially just breaking up the big block comment at the top into
little pieces.
|
|
|
|
|
|
| |
Because this is a version-based check and shouldn't change any runtime,
we can just calculate it once as a variable local and persistent to this
script, and then store it for reference by the toggling function.
|
|
|
|
|
| |
It makes more sense to discuss how something wraps after configuring
whether it wraps at all.
|
|
|
|
|
| |
Don't change the value of these options for all buffers with the \w and
\b maps, just the current one.
|
|
|
|
|
|
| |
'linebreak', 'showbreak', 'breakindent', and 'breakindent' are only
relevant when 'wrap' is on, so it makes sense for their settings to be
grouped together.
|
|
|
|
| |
This is more idiomatic, and explicitly initialises the result variable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In addition to its existing functionality of removing trailing spaces
from the ends of lines, this change has the function remove lines at the
end of the file afterwards if they contain no non-whitespace characters,
based on its observations during the line iteration.
This uses the older VimL functions line() and col() in preference to the
newer winsaveview() and winrestview() to restore the cursor position
after the range :delete moves it, so that this will hopefully work even
on older versions of Vim; that is not yet tested.
I am surprised that there is no line deletion function to match e.g.
getline(), setline(), but it does seem to be the case:
<https://groups.google.com/d/msg/vim_use/TY9NmJXh8EU/iFjOUg68AekJ>
|
|
|
|
|
| |
No functional changes; this is just to make it a little clearer before I
add some more functionality to it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use a slightly more verbose but more compatible `:while` loop to
accommodate very old versions of Vim that do not have `:for`.
Vim 6.2 gives the following terminal output when the `:for` version is
run:
Error detected while processing /home/tom/.vim/config/whitespace.vim:
line 13:
E193: :endfunction not inside a function
However, it accepts this new version with no complaint, and the function
seems to work properly.
|
|
|
|
|
|
| |
With the `scriptencoding` call that was in this file removed in 1834c08,
there's no longer anything that's sensitive to the order in which this
option is loaded relative to any other options.
|
|
|
|
|
|
|
| |
There aren't actually any characters outside ASCII in any of the
configuration, and for this to work they would need to have the
`scriptencoding` at the head of that file, not at the top of the
`.vimrc` as here, so I've just removed it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The Google VimScript Style Guide says
<https://google.github.io/styleguide/vimscriptguide.xml#Naming>:
>In general, use plugin-names-like-this, FunctionNamesLikeThis,
>CommandNamesLikeThis, augroup_names_like_this,
>variable_names_like_this.
Adjusted variable, function, and `augroup` names accordingly, including
setting script scope for some of the functions and their calls (`s:` and
`<SID>` prefixes).
Initially I tried using `prefix#`, but it turns out that this is a
namespacing contention for publically callable functions like
`pathogen#infect`, and none of these functions need to be publically
callable.
|
|
|
|
| |
This was mistakenly moved from the monolithic .vimrc file in 07fc8ce.
|
|
|
|
|
| |
We're referring to the installed path and not the sourced path in this
paragraph.
|
|
|
|
| |
perlcritic.com does not seem to support HTTPS.
|
|\
| |
| |
| |
| |
| | |
The Vim configuration, excluding the submodule plugin bundles, now
passes a strict run of the vim-vint tool. There's also now a `lint-vim`
target in the Makefile.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since I know there's a usable tool for this now in vim-vint, I may as
well make a target for my own convenience later.
Updated the README.markdown documentation of the `lint-*` targets,
restructuring the paragraph into a nested list for clarity. Also updated
the `dotfiles(7)` manual page to reflect those changes.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
vim-vint says:
>Do not use a command that has unintended side effects (see Google
>VimScript Style Guide (Dangerous))
>Avoid commands that rely on user settings (see Google VimScript Style
>Guide (Fragile))
In both cases, it's referring to the use of :substitute in this file.
The Google style guide on which vim-vint is based says <https://google.github.io/styleguide/vimscriptguide.xml?showone=Fragile_commands#Fragile_commands>:
>Avoid :s[ubstitute], as its behavior depends upon a number of local
>settings.
It also says <https://google.github.io/styleguide/vimscriptguide.xml?showone=Dangerous_commands#Dangerous_commands>:
> Avoid using :s[ubstitute] as it moves the cursor and prints error
> messages. Prefer functions (such as search()) better suited to
> scripts.
>
> For many vim commands, functions exist that do the same thing with
> fewer side effects. See :help functions() for a list of built-in
> functions.
I reimplemented the function based on an answer I found by `romainl` to
a similar question: <https://vi.stackexchange.com/a/5962>
There are plenty of other trailing-whitespace-stripping solutions out
there, but this one can be mine. It now passes vim-vint. I'll make a
plugin out of it at some point.
The \m\C shibboleth at the front of the regular expression is to enforce
the 'magic' setting for the regular expression, and to enforce
case-sensitivity. This is recommended by the style guide:
<https://google.github.io/styleguide/vimscriptguide.xml?showone=Dangerous_commands#Regular_Expressions
> Prefix all regexes with \m\C.
>
> In addition to the case sensitivity settings, regex behavior depends
> upon the user's nomagic setting. To make regexes act like nomagic and
> noignorecase are set, prepend all regexes with \m\C.
>
> You are welcome to use other magic levels (\v) and case sensitivities
> (\c) so long as they are intentional and explicit.
Before I committed this, I checked with vint -s to include stylistic
recommendations as well, and it insisted on l: prefixes to the `li` and
`line` variable to make them explicitly local to the function, so I did
that, too.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
vim-vint says:
>Avoid commands that rely on user settings (see Google VimScript Style
>Guide (Fragile))
The style guide explains:
>Always use normal! instead of normal. The latter depends upon the
>user's key mappings and could do anything.
Can't argue with that...
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
vim-vint says:
>Prefer single quoted strings (see Google VimScript Style Guide
>(Strings))
Perl::Critic warns about a similar thing; don't use doublequotes if you
don't need to expand e.g. \n, \r or interpolate variables. Makes sense
to me.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
vim-vint says:
>Do not use nocompatible which has unexpected effects (see :help
>nocompatible)
I can't actually find anything in the help item it references that says
that setting 'nocompatible' is bad, but the situation in which it's
needed is very niche anyway; per the removed comment:
>Don't make any effort to be compatible with vi, use more sensible
>settings. This is only here in case this file gets loaded explicitly
>with -u; the mere existence of a ~/.vimrc file already turns this off.
We'll just leave it out, and see if anything bad happens..."if in doubt,
rip it out".
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
I got a set of warnings from vim-vint about using just "==" for these
comparisons:
>Use robust operators `==#` or `==?` instead of `==` (see Google
>VimScript Style Guide (Matching))
It does seem a lot more sensible to be explicit about case sensitivity,
and not to lean on the configured 'ignorecase' value, especially if the
user changes it.
|
|/
|
|
|
| |
This was mistakenly moved along with some indentation settings in
9858af6.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I had four spaces, but with a 'shiftwidth' of 2, 6 is the conventional
value.
From :help ft-vim-indent:
>For indenting Vim scripts there is one variable that specifies the
>amount of indent for a continuation line, a line that starts with a
>backslash:
>
> :let g:vim_indent_cont = &sw * 3
>
>Three times shiftwidth is the default value.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Move the rule setting the custom b:is_ksh variable used for this
workaround (established in 52615f6) into an ftplugin file, rather than
into ftdetect; the latter seems a much more appropriate place since by
this point we've definitely decided the file type is "sh".
From the revised comment in this changeset:
>Setting g:is_posix above also prompts Vim's core syntax/sh.vim script
>to set g:is_kornshell and thereby b:is_kornshell to the same value as
>g:is_posix.
>
>That's very confusing, so before it happens we'll copy b:is_kornshell's
>value as determined by filetype.vim and ~/.vim/ftdetect/sh.vim into a
>custom variable b:is_ksh, before its meaning gets confused.
>
>b:is_ksh as a name is more inline with b:is_bash and b:is_sh, anyway,
>so we'll just treat b:is_kornshell like it's both misnamed and broken.
>
>We can then switch on our custom variable in ~/.vim/after/syntax/sh.vim
>to apply settings that actually *are* unique to Korn shell and its
>derivatives.
|
|
|
|
|
| |
This and the other files in the now-removed vim/after/ftdetect directory
were moved to vim/ftdetect in f8af47b.
|
| |
|
|
|
|
|
|
| |
These trailing equals signs were vestigial from an attempt in f33111b to
use what I thought was a backwards-compatible syntax for resetting a
local option to its global state.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
My old 6.2 version of Vim tolerates neither `option<` nor `option=`
syntax for resetting local versions of these options, so I'm just going
to have to guard against running those commands on ancient Vim for now.
They seem to work correctly on 7.0.
:setlocal shiftwidth<
Number required after =: shiftwidth<
:setlocal shiftwidth=
Number required after =: shiftwidth=
:setlocal shiftwidth=0
Argument must be positive: shiftwidth=0
|
|
|
|
|
|
|
| |
For compatibility with older versions of Vim, string-based (not boolean)
options need to be reset with `setlocal option=`, rather than `<`. New
versions of Vim tolerate the latter for the string values, and do what
you meant.
|
|
|
|
|
|
| |
This will mean the correct value is restored for filetypes that source
this file as part of their indent processing, and won't stay broken if
we switched from e.g. CSV or TSV.
|
|
|
|
|
|
| |
Remove the duplicated code instated to use the global defaults for
indent-related options and put it into a common file to source with
:runtime.
|
|
|
|
|
|
| |
I'm still getting used to the structure of the configuration here, and
had mistakenly put these indent-related settings into files in the
ftplugin directory.
|
|
|
|
|
|
|
|
|
|
| |
For some languages in which I write often: C, HTML, Perl, PHP, and
shell scripts.
All of these values presently match the defaults specified in
config/indent.vim, but for languages I commonly use it's probably
appropriate to have files to set the indent settings explicitly anyway,
especially if we switched from a filetype with different values.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Vim does not seem to have any built-in detection or settings for CSV or
TSV files, so I've added a couple here, based on filename patterns
matching the .csv and .tsv extensions.
If either of these types are detected, the 'autoindent' and 'expandtab'
options are both switched off, as they're undesirable, especially in
TSVs where a literal tab is almost certainly what's intended.
Ideally, these same two setting would apply to any filetype not
otherwise categorisable, but I can't figure out a way to do that safely
yet; there was an attempt made in d3d998c.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use this recommended syntax in the custom ftplugin settings.
Seems to be the recommended way to set filetype idempotently, and is
present even in very old Vim (6.2 tested).
From the Vim documentation for :setfiletype:
>Set the 'filetype' option to {filetype}, but only if not done yet in a
>sequence of (nested) autocommands. This is short for:
> :if !did_filetype()
> : setlocal filetype={filetype}
> :endif
>This command is used in a filetype.vim file to avoid setting the
>'filetype' option twice, causing different settings and syntax files to
>be loaded.
|
|
|
|
|
|
| |
Use four spaces for the indent of lines that are continuations of the
previous line, using VimL's bizarre backslashed syntax, to keep them
distinct from the indentation to show control structures.
|
|
|
|
|
|
| |
Put the patterns together with a comma to keep them in the same rule. I
suspect my original intention was to keep things clear, but this doesn't
seem so bad now.
|
|
|
|
|
|
|
|
|
|
| |
Clear autocommand definitions for each of the ftdetect augroups with
`autocmd!` as the first command within them. This avoids ending up with
doubled-up autocmd definitions if the configuration file is re-sourced,
and is pretty standard good Vimscript practice.
It's done correctly elsewhere in my Vim configuration, for example in
config/undo.vim, but it's been unintentionally omitted here.
|
|
|
|
|
|
|
| |
This requires more careful thought to avoid stale local options
(:setlocal) for appropriate filetypes.
This reverts commit d3d998c68c335b35525172c700ff958d5a016399.
|