Code Monkey home page Code Monkey logo

lessspace.vim's People

Contributors

mephistophiles avatar thirtythreeforty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lessspace.vim's Issues

Whitespace cleanup after non-insert mode line manipulations

Hi George,

thanks for your very useful VIM plugin. I started using it a while back to get rid of trailing whitespace, especially in code checked into version control systems. Though your plugin does help a lot, there are still a number of whitespace errors remaining. I think the main source of these, at least in my case, is the deletion of trailing parts of a line, e.g. comments. For example, consider a line like
my $empty_string = ""; # the empty string
where I later decide to remove the comment. I would usually do this by going to this line and hitting f#d$, which will remove the comment, but will not remove the whitespace after ";", yielding a whitespace error.

Would it be possible to add support to your plugin for removing these types of whitespace errors, too? More precisely, I think it would be sensible to remove whitespace not just from all lines visited in insert mode, but also from all lines which have been manipulated by deletions (d), regexp substitutions or pastes. What do you think?

Regards,
Felix

%s doesn't trigger stripping

The test file I used (note trailing whitespace on each line):

some spaces here     

some more here     

and again      

The test command was :%s/here/there/. After running the command, affected lines still have their trailing whitespace.

This was on Vim 8.1 (my own compiled version).

Automatically, annoyingly removes spaces as you type with codi.vim

As you type into the buffer when Codi is started, Codi evaluates the code. Unfortunately, a side effect of this behaviour is that this plug-in decides to strip the white space as you type - as you are still in insert mode. This is rather annoying, especially when you are trying to type code that is indented.

To illustrate this behaviour, see this:

ezgif-1-d3a9dd2f53

I have mentioned this in this issue here metakirby5/codi.vim#90

%s causes the entire file to have whitespace stripped

file (add some whitespace to each line when testing):

private bla() {
  sdfkljsdlkfj sdkl fjask ljakl sjdfkl jkl  
}   

open vim with that file and make sure that you have the whitespace saved.

now open vim and have lessspace enabled. run :%s/private/public/<CR> and now the whitespace is stripped from every line, not just the 1st line (which would be the ideal behaviour)

Option to run only on save

It is a bit less intrusive/surprising that way. I'm not sure this possible based on how the plug in is permitted. If not possible, it's not a big deal

Override C-r mapping in insert mode

Hello, I'm hoping this is a solved problem as its a pretty common case (from my POV at least) but is it possible to override my C-r mapping to disable LessSpace until I choose a register?

Quick example to demonstrate the problem, I'll use | to represent the cursor and assume insert mode:
Register " contains: this plugin is awesome!

new_string = "Thanks, |

When pressing C-r " the trailing whitespace is removed and the register is pasted leaving us with the following:

new_string = "Thanks,this plugin is awesome!

I've tried manually toggling LessSpace but its not ideal, I've also experimented with wrapping registers.nvim C-r command with lessspace#TemporaryDisableBegin/End but I've had no luck [0].

[0] - Gee19/registers.nvim@d38ef97

Any workarounds would be awesome

Apparent conflict with Whitespaste plugin

With Whitespaste installed, and given this sample file:

fn foo() {

}

fn baz() {
	do_something();
	do_something_else();
}

Yank yy the empty line from foo and try to paste it before the do_something() call or after the do_something_else call (essentially, next to a delimiter).

This error is thrown:

Error detected while processing function lessspace#OnTextChanged[18]..lessspace#MaybeStripWhitespace:                                                                                          
line   23:                                                                                                                                                                                     
E493: Backwards range given: 12 , 11 s/\v\s+$//e                                                                                                                                               ```

Strips unchanged lines then can't undo changes

I edit a file with blanks at end of, for example, lines 5 and 10. If I change line 5 and remain in insert mode and move down with down-arrow to line 10 and, remaining in insert mode, move back to line 5 and then exit insert mode, the blanks at the end of 5 go away. But they also go away at line 10 (which I did not change at all).
Ideally, only changed lines should have their trailing whitespace removed.
Then if I try to undo these changes, nothing happens. The change on line 5 won't undo and the blanks at the end of 5 and 10 won't come back.
Only if I do command :LessSpace! to disable the plugin can I undo any previous changes.
(Hopefully I installed in right. I just put the entire cloned project lessspace.vim/ under ~/.vim/plugin/)

Try stripping on CursorHold autocommand, not InsertLeave

This would prevent the slight cursor motion in cases like the autocommand in #5:

inoremap <c-f> <c-g>u<Esc>[s1z=`]a<c-g>u

However there may be other edge cases that make this unworkable, or this may be surprising to the user.

In any case, it would be nice to have an implementation to try it out with.

A couple points:

  • This may be completely invisible to the user if their updatetime is sufficiently low.
  • When changes are made in insert mode, the InsertLeave hook should not do anything except record the end location of the cursor. The strip is now "pending."
  • When CursorHold is triggered, LessSpace should execute any pending strip.
  • When the file is saved or Vim exits or the buffer closes or the user changes buffers, LessSpace should execute any pending strip.
  • When changes are made in normal mode before CursorHold is triggered, what should LessSpace do? This is one such edge case that I'm not sure how to work around yet: It could:
    • Execute the pending strip before the normal mode changes are made. This could be surprising if the user executes a command that would have interacted with the removed whitespace.
    • Execute the pending strip after the normal mode changes are made, including any stripping of those changes otherwise performed. This might be surprising to LessSpace if the lines it was intending to strip are moved around, since its "marks" aren't moved around like Vim's are.
    • Drop the pending strip on the floor. This is probably wrong, but is definitely simple!

Error detected while processing function lessspace#OnInsertExit[1]..lessspace#MaybeStripWhitespace: line 33

I keep receiving below error message once a few hours. It usually happens when I press <ESC> at the end of file, but I couldn't find a consistent way for reproducing it. Removing lines at the end of file may be causing this somehow, but I'm not sure as I couldn't intentionally trigger this message in any way. I suspect some kind of race condition.

I didn't realize any other issues caused by this other than printing error message on the screen.

Error detected while processing function lessspace#OnInsertExit[1]..lessspace#MaybeStripWhitespace:                                                                                                                
line   33:                                                                                                                                                                                                         
E16: Invalid range: 1 , 3 s/\v\s+$//e

Another one:

Error detected while processing function lessspace#OnInsertExit[1]..lessspace#MaybeStripWhitespace:                                                                                                                
line   33:                                                                                                                                                                                                         
E16: Invalid range: 12 , 14 s/\v\s+$//e

E16: Invalid range

Thank you for an amazingly useful plugin!

Unfortunately I sometimes run into problems when undoing or redoing changes on the last line of a file. I'm not sure what types of changes cause this exactly, but I ran into this on several different occasions. It's mostly related to plugins and/or mappings I believe, but maybe it can occur on manual edits.

Just now it happened again so here is one way to reliably trigger this using the vim-surround plugin:

type a word into the last/only line of a file:

this
is
the
last
line

with the cursor over line, type ysiw"<esc> to wrap it in quotation marks.

this
is
the
last
"line"

undoing this change with u triggers the error as well as redoing the change with <c-r>:

Error detected while processing function lessspace#OnTextChanged[15]..lessspace#
MaybeStripWhitespace:                                                           
line   13:                                                                      
E16: Invalid range: 5 , 6 s/\v\s+$//e                                           
Press ENTER or type command to continue      

The error message can be easily dismissed, but it would of course be preferable to not get the error :)
Maybe you can do something about this, thank you for your work in any case.

By the way I'm using lessspace with neovim v0.1.7 on linux.

Breaks a common reverse spell-checking mapping.

Thank you for making this plugin, it's almost everything I'm looking for. Unfortunately for me it frequently messes up a mapping for auto-correcting the last spelling mistake before the cursor.

inoremap <c-f> <c-g>u<Esc>[s1z=`]a<c-g>u
nnoremap <c-f> [s1z=<c-o>

If I tpyed this sentence wrong. And hit <c-f> right here|
Then the sentence would be corrected and the cursor would jump back to the correct spot. Everything is dandy.

However if I typed TIHS sentence wrong. And hit <c-f> right here | (notice the space)
Then I think the `] mark gets overwritten and the cursor ends up after the first character of the line.

Any suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.