Module: VER::Methods::Delete
- Included in:
- VER::Methods
- Defined in:
- lib/ver/methods/delete.rb
Instance Method Summary collapse
-
#change_line(count = 1) ⇒ Object
Wrapper for [kill_line] that starts insert mode after killing
count
lines. - #change_motion(motion, count = 1) ⇒ Object
-
#delete(*indices) ⇒ Object
Delete text between
indices
. -
#delete_line(count = 1) ⇒ Object
Delete current line and upto
count
subsequent lines. -
#delete_motion(motion, count = 1) ⇒ Object
Given a
motion
, this method will execute a virtual movement with thecount
argument and [delete] the corresponding indices. -
#delete_trailing_whitespace ⇒ Object
Tag and delete all trailing whitespace in the current buffer.
-
#kill(*indices) ⇒ Object
Copy text between
indices
and delete it. -
#kill_line(count = 1) ⇒ Object
Copy current line and upto
count
subsequent lines and delete them. -
#kill_motion(motion, count = 1) ⇒ Object
Given a
motion
, this method will execute a virtual movement with thecount
argument and [kill] the corresponding indices.
Instance Method Details
#change_line(count = 1) ⇒ Object
Wrapper for [kill_line] that starts insert mode after killing count
lines.
66 67 68 69 |
# File 'lib/ver/methods/delete.rb', line 66 def change_line(count = 1) kill_line(count) start_insert_mode end |
#change_motion(motion, count = 1) ⇒ Object
4 5 6 7 |
# File 'lib/ver/methods/delete.rb', line 4 def change_motion(motion, count = 1) delete_motion(motion, count) start_insert_mode end |
#delete(*indices) ⇒ Object
Delete text between indices
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ver/methods/delete.rb', line 78 def delete(*indices) indices_size = indices.size return if indices_size == 0 undo_record do |record| if indices_size == 1 record.delete(indices.first) else indices.each_slice(2) do |from, to| next if from == to record.delete(from, to) end end end end |
#delete_line(count = 1) ⇒ Object
Delete current line and upto count
subsequent lines.
39 40 41 42 43 44 |
# File 'lib/ver/methods/delete.rb', line 39 def delete_line(count = 1) from = index('insert linestart') count = count.abs - 1 to = index("#{from.y + count}.#{from.x} lineend + 1 char") delete(from, to) end |
#delete_motion(motion, count = 1) ⇒ Object
Given a motion
, this method will execute a virtual movement with the count
argument and [delete] the corresponding indices.
17 18 19 |
# File 'lib/ver/methods/delete.rb', line 17 def delete_motion(motion, count = 1) delete(*virtual_movement(motion, count)) end |
#delete_trailing_whitespace ⇒ Object
Tag and delete all trailing whitespace in the current buffer.
72 73 74 75 |
# File 'lib/ver/methods/delete.rb', line 72 def delete_trailing_whitespace tag_all_trailing_whitespace execute :delete, *tag_ranges('invalid.trailing-whitespace').flatten end |
#kill(*indices) ⇒ Object
Copy text between indices
and delete it.
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ver/methods/delete.rb', line 99 def kill(*indices) if indices.size > 2 deleted = indices.each_slice(2).map{|left, right| get(left, right) } else deleted = get(*indices) end copy(deleted) delete(*indices) end |
#kill_line(count = 1) ⇒ Object
Copy current line and upto count
subsequent lines and delete them.
52 53 54 55 56 57 |
# File 'lib/ver/methods/delete.rb', line 52 def kill_line(count = 1) from = index('insert linestart') count = count.abs - 1 to = index("#{from.y + count.to_i}.#{from.x} lineend + 1 char") kill(from, to) end |
#kill_motion(motion, count = 1) ⇒ Object
Given a motion
, this method will execute a virtual movement with the count
argument and [kill] the corresponding indices.
29 30 31 |
# File 'lib/ver/methods/delete.rb', line 29 def kill_motion(motion, count = 1) kill(*virtual_movement(motion, count)) end |