комманда b -> перемещает курсора в начало слова слева от курсора

master
serr 2025-02-04 21:08:48 +03:00
parent 5cf89f71f9
commit f76504249b
1 changed files with 10 additions and 0 deletions

View File

@ -93,6 +93,16 @@ class VimModel:
self.currentCol = right_space_index
else:
self.currentCol = len(self.displayBuffer[self.currentLine])
case "b": # Перемещает курсор в конец в начало слова слева от курсора
line = ''.join(self.displayBuffer[self.currentLine])
non_space_index = next((i for i in range(self.currentCol - 1, -1, -1) if line[i] != ' '), None)
if non_space_index is not None:
left_space_index = line.rfind(' ', 0, non_space_index)
if left_space_index != -1:
self.currentCol = left_space_index + 1
else:
self.currentCol = 0
def Enter(self) -> None:
# Разделяем текущую строку на две части