22Vi-specific commands for pyrepl.
33"""
44
5- from .commands import Command , MotionCommand , KillCommand
5+ from .commands import Command , MotionCommand , KillCommand , delete
66from . import input as _input
77from .types import ViFindDirection
88from .trace import trace
99
1010
11+ class ViKillCommand (KillCommand ):
12+ """Base class for Vi kill commands that modify the buffer."""
13+ modifies_buffer = True
14+
15+
1116# ============================================================================
1217# Vi-specific Motion Commands
1318# ============================================================================
@@ -112,7 +117,12 @@ def do(self) -> None:
112117# Delete Commands
113118# ============================================================================
114119
115- class vi_delete_word (KillCommand ):
120+ class vi_delete (delete ):
121+ """Delete character under cursor (x)."""
122+ modifies_buffer = True
123+
124+
125+ class vi_delete_word (ViKillCommand ):
116126 """Delete from cursor to start of next word (dw)."""
117127 def do (self ) -> None :
118128 r = self .reader
@@ -122,28 +132,28 @@ def do(self) -> None:
122132 self .kill_range (r .pos , end )
123133
124134
125- class vi_delete_line (KillCommand ):
135+ class vi_delete_line (ViKillCommand ):
126136 """Delete entire line content (dd)."""
127137 def do (self ) -> None :
128138 r = self .reader
129139 self .kill_range (r .bol (), r .eol ())
130140
131141
132- class vi_delete_to_bol (KillCommand ):
142+ class vi_delete_to_bol (ViKillCommand ):
133143 """Delete from cursor to beginning of line (d0)."""
134144 def do (self ) -> None :
135145 r = self .reader
136146 self .kill_range (r .bol (), r .pos )
137147
138148
139- class vi_delete_to_eol (KillCommand ):
149+ class vi_delete_to_eol (ViKillCommand ):
140150 """Delete from cursor to end of line (d$ or D)."""
141151 def do (self ) -> None :
142152 r = self .reader
143153 self .kill_range (r .pos , r .eol ())
144154
145155
146- class vi_delete_char_before (KillCommand ):
156+ class vi_delete_char_before (ViKillCommand ):
147157 """Delete character before cursor (X)."""
148158 def do (self ) -> None :
149159 r = self .reader
@@ -343,7 +353,7 @@ def do(self) -> None:
343353# Change Commands
344354# ============================================================================
345355
346- class vi_change_word (KillCommand ):
356+ class vi_change_word (ViKillCommand ):
347357 """Change from cursor to end of word (cw)."""
348358 def do (self ) -> None :
349359 r = self .reader
@@ -354,15 +364,15 @@ def do(self) -> None:
354364 r .enter_insert_mode ()
355365
356366
357- class vi_change_to_eol (KillCommand ):
367+ class vi_change_to_eol (ViKillCommand ):
358368 """Change from cursor to end of line (C)."""
359369 def do (self ) -> None :
360370 r = self .reader
361371 self .kill_range (r .pos , r .eol ())
362372 r .enter_insert_mode ()
363373
364374
365- class vi_substitute_char (KillCommand ):
375+ class vi_substitute_char (ViKillCommand ):
366376 """Delete character under cursor and enter insert mode (s)."""
367377 def do (self ) -> None :
368378 r = self .reader
0 commit comments