Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· openaiHugging Face Suzhen/CodeChat

in vim set ctrl+leftmouse click on line deletes that line

  1. User

    in vim set ctrl+leftmouse click on line deletes that line

  2. Assistant

    To achieve this functionality in Vim, you can map the Ctrl+LeftMouseClick combination to delete the line under the cursor.

    Add the following line to your .vimrc file:

    nnoremap <C-LeftMouse> dd
    

    Save the .vimrc file and restart Vim for the changes to take effect.

    Now, when you press Ctrl+LeftMouseClick on a line in normal mode, the currently selected line will be deleted.

  3. User

    it deletes the current but i wanna delete the line on which i will click on

  4. Assistant

    Apologies for the confusion. If you want to delete the line on which you click with Ctrl+LeftMouse, you can use the following mapping instead:

    :nnoremap <C-LeftMouse> :<C-U>execute 'normal! '.getline('.').'dd'<CR>
    

    This mapping will execute the dd command on the line at which you press Ctrl+LeftMouse, effectively deleting that line.

    Again, add this line to your .vimrc file, save it, and restart Vim for the changes to take effect.

  5. User

    first echo the line number on which i click

  6. Assistant

    Apologies for the confusion. To echo the line number on which you click using Ctrl+LeftMouse and then delete the line, you can use the following mapping:

    :nnoremap <C-LeftMouse> :<C-U>execute 'echo "Deleting line: " . line(".")' \| execute line(".") . 'delete'<CR>
    

    This mapping will echo the line number of the line you clicked on, and then delete that line.

    Again, add this line to your .vimrc file, save it, and restart Vim for the changes to take effect.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.