| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Including renaming big_file.vim and accompanying functions yet again, to
big_file_options.vim.
Trying to keep complex autocmd and mapping definitions on long lines
broken up semantically; definition and options on one line, patterns or
mapping key on the next, and the command to run on the last.
Also trying to make sure that <silent>, <buffer>, and <unique> are
applied in the correct places, and that all mapping commands are using
the :<C-U> idiom for the command prefix.
|
|
|
|
|
|
| |
This properly abstracts out the StripTrailingWhitespace mapping rather
than forcing it to <leader>x within the plugin itself. A bit nicer this
way.
|
| |
|
|
|
|
|
| |
Just in case somebody tried to use it to strip whitespace only from a
selected range. It could maybe be extended to do this somehow.
|
|
|
|
|
| |
It makes much more sense in this file than it did in the whitespace
configuration file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
The StripTrailingWhitespace() function should perhaps be its own plugin.
|