Delete but not cut a line in Vim

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












This is not duplicate of delete line in vi, it's asking different question. I'd like to delete a line without cutting it (placing it in clipboard).



I'd like to copy part of line, delete a line and then paste just that part of line somewhere else. Using v3w, dd and then p pastes whole line.










share|improve this question







New contributor




Dread Boy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    This question is conflating the unnamed register in VIM with an X11 clipboard selection, accessible in VIM via a selection register.
    – JdeBP
    2 hours ago











  • @JdeBP for advanced VI user it might be conflicting because we have knowledge of Vi, but for novice it makes sense as he is not aware of both neither named nor unnamed registers in Vi; but pointing from here to those questions might be good addition, if you have exact links feel free to add to my answer.
    – Drako
    2 hours ago











  • "those questions" has no antecedent. I did not talk about any other questions than this one.
    – JdeBP
    2 hours ago










  • Now that the subject of other questions has been raised by someone else, see unix.stackexchange.com/questions/7788 from 7 years ago.
    – JdeBP
    1 hour ago










  • why not: v3w "_dd p ?
    – JJoao
    1 hour ago














up vote
2
down vote

favorite












This is not duplicate of delete line in vi, it's asking different question. I'd like to delete a line without cutting it (placing it in clipboard).



I'd like to copy part of line, delete a line and then paste just that part of line somewhere else. Using v3w, dd and then p pastes whole line.










share|improve this question







New contributor




Dread Boy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    This question is conflating the unnamed register in VIM with an X11 clipboard selection, accessible in VIM via a selection register.
    – JdeBP
    2 hours ago











  • @JdeBP for advanced VI user it might be conflicting because we have knowledge of Vi, but for novice it makes sense as he is not aware of both neither named nor unnamed registers in Vi; but pointing from here to those questions might be good addition, if you have exact links feel free to add to my answer.
    – Drako
    2 hours ago











  • "those questions" has no antecedent. I did not talk about any other questions than this one.
    – JdeBP
    2 hours ago










  • Now that the subject of other questions has been raised by someone else, see unix.stackexchange.com/questions/7788 from 7 years ago.
    – JdeBP
    1 hour ago










  • why not: v3w "_dd p ?
    – JJoao
    1 hour ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











This is not duplicate of delete line in vi, it's asking different question. I'd like to delete a line without cutting it (placing it in clipboard).



I'd like to copy part of line, delete a line and then paste just that part of line somewhere else. Using v3w, dd and then p pastes whole line.










share|improve this question







New contributor




Dread Boy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











This is not duplicate of delete line in vi, it's asking different question. I'd like to delete a line without cutting it (placing it in clipboard).



I'd like to copy part of line, delete a line and then paste just that part of line somewhere else. Using v3w, dd and then p pastes whole line.







vim






share|improve this question







New contributor




Dread Boy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Dread Boy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Dread Boy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









Dread Boy

1111




1111




New contributor




Dread Boy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Dread Boy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Dread Boy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    This question is conflating the unnamed register in VIM with an X11 clipboard selection, accessible in VIM via a selection register.
    – JdeBP
    2 hours ago











  • @JdeBP for advanced VI user it might be conflicting because we have knowledge of Vi, but for novice it makes sense as he is not aware of both neither named nor unnamed registers in Vi; but pointing from here to those questions might be good addition, if you have exact links feel free to add to my answer.
    – Drako
    2 hours ago











  • "those questions" has no antecedent. I did not talk about any other questions than this one.
    – JdeBP
    2 hours ago










  • Now that the subject of other questions has been raised by someone else, see unix.stackexchange.com/questions/7788 from 7 years ago.
    – JdeBP
    1 hour ago










  • why not: v3w "_dd p ?
    – JJoao
    1 hour ago












  • 1




    This question is conflating the unnamed register in VIM with an X11 clipboard selection, accessible in VIM via a selection register.
    – JdeBP
    2 hours ago











  • @JdeBP for advanced VI user it might be conflicting because we have knowledge of Vi, but for novice it makes sense as he is not aware of both neither named nor unnamed registers in Vi; but pointing from here to those questions might be good addition, if you have exact links feel free to add to my answer.
    – Drako
    2 hours ago











  • "those questions" has no antecedent. I did not talk about any other questions than this one.
    – JdeBP
    2 hours ago










  • Now that the subject of other questions has been raised by someone else, see unix.stackexchange.com/questions/7788 from 7 years ago.
    – JdeBP
    1 hour ago










  • why not: v3w "_dd p ?
    – JJoao
    1 hour ago







1




1




This question is conflating the unnamed register in VIM with an X11 clipboard selection, accessible in VIM via a selection register.
– JdeBP
2 hours ago





This question is conflating the unnamed register in VIM with an X11 clipboard selection, accessible in VIM via a selection register.
– JdeBP
2 hours ago













@JdeBP for advanced VI user it might be conflicting because we have knowledge of Vi, but for novice it makes sense as he is not aware of both neither named nor unnamed registers in Vi; but pointing from here to those questions might be good addition, if you have exact links feel free to add to my answer.
– Drako
2 hours ago





@JdeBP for advanced VI user it might be conflicting because we have knowledge of Vi, but for novice it makes sense as he is not aware of both neither named nor unnamed registers in Vi; but pointing from here to those questions might be good addition, if you have exact links feel free to add to my answer.
– Drako
2 hours ago













"those questions" has no antecedent. I did not talk about any other questions than this one.
– JdeBP
2 hours ago




"those questions" has no antecedent. I did not talk about any other questions than this one.
– JdeBP
2 hours ago












Now that the subject of other questions has been raised by someone else, see unix.stackexchange.com/questions/7788 from 7 years ago.
– JdeBP
1 hour ago




Now that the subject of other questions has been raised by someone else, see unix.stackexchange.com/questions/7788 from 7 years ago.
– JdeBP
1 hour ago












why not: v3w "_dd p ?
– JJoao
1 hour ago




why not: v3w "_dd p ?
– JJoao
1 hour ago










2 Answers
2






active

oldest

votes

















up vote
2
down vote













You're looking for the black hole register (:help quote_). If you prepend "_ to a delete command, the contents will just be gone. So, to delete and keep the next three words, and then get rid of the entire line, you'd use d3w"_dd.



Advanced mapping



That use case of keeping a part of the line while removing the complete line is a common one; I've written a set of mappings for that:



"["x]dDD Delete the characters under the cursor until the end
" of the line and [count]-1 more lines [into register x],
" and delete the remainder of the line (i.e. the
" characters before the cursor) and possibly following
" empty line(s) without affecting a register.
"["x]dDmotion Delete text that motion moves over [into register x]
" and delete the remainder of the line(s) and possibly
" following empty line(s) without affecting a register.
"Visual["x],dD Delete the highlighted text [into register x] and delete
" the remainder of the selected line(s) and possibly
" following empty line(s) without affecting a register.
function! s:DeleteCurrentAndFollowingEmptyLines()
let l:currentLnum = line('.')
let l:cnt = 1
while l:currentLnum + l:cnt < line('$') && getline(l:currentLnum + l:cnt) =~# '^s*$'
let l:cnt += 1
endwhile

return '"_' . l:cnt . 'dd'
endfunction
nnoremap <expr> <SID>(DeleteCurrentAndFollowingEmptyLines) <SID>DeleteCurrentAndFollowingEmptyLines()
nnoremap <script> dDD D<SID>(DeleteCurrentAndFollowingEmptyLines)
xnoremap <script> ,dD d<SID>(DeleteCurrentAndFollowingEmptyLines)
function! s:DeleteCurrentAndFollowingEmptyLinesOperatorExpression()
set opfunc=DeleteCurrentAndFollowingEmptyLinesOperator
let l:keys = 'g@'

if ! &l:modifiable || &l:readonly
" Probe for "Cannot make changes" error and readonly warning via a no-op
" dummy modification.
" In the case of a nomodifiable buffer, Vim will abort the normal mode
" command chain, discard the g@, and thus not invoke the operatorfunc.
let l:keys = ":call setline('.', getline('.'))<CR>" . l:keys
endif

return l:keys
endfunction
function! DeleteCurrentAndFollowingEmptyLinesOperator( type )
try
" Note: Need to use an "inclusive" selection to make `] include the last
" moved-over character.
let l:save_selection = &selection
set selection=inclusive

execute 'silent normal! g`[' . (a:type ==# 'line' ? 'V' : 'v') . 'g`]"' . v:register . 'y'

execute 'normal!' s:DeleteCurrentAndFollowingEmptyLines()
finally
if exists('l:save_selection')
let &selection = l:save_selection
endif
endtry
endfunction
nnoremap <expr> dD <SID>DeleteCurrentAndFollowingEmptyLinesOperatorExpression()





share|improve this answer



























    up vote
    1
    down vote













    you can copy that part that you want to use in named buffer and paste from there, for example:



    "ay3w


    this will yank 3 words in named buffer a
    and



    "ap


    would paste from named buffer a later; also you could first delete 3 words and then delete all line and later paste with



    "2p


    this would paste 2nd from last deletion from deletion buffer;
    also following suggestions on comments as this is VIM tagged question - there is native VIM solution for this (does not work on Vi):



    y3w then in new place "0p


    VIM has native feature to keep last yank in 0 registry.






    share|improve this answer






















    • Why not use VIM's black hole register?
      – JdeBP
      2 hours ago










    • @JdeBP are you serious? Did you even read the answer - second option in my answer is exactly that - I only did not name it black hole register - some what old style naming - deletion registry but essentially same thing numbered buffer from 1-9 keeping track of last changes in file
      – Drako
      2 hours ago











    • The second option in your answer is not the black hole register. The black hole register is not a numbered register.
      – JdeBP
      2 hours ago










    • @JdeBP read here: blog.dreasgrech.com/2010/06/vims-black-hole-register.html it seems that I have had partially wrong assumption that it the same, but essentially it's same with expanded functionality, that definitely is not needed here; also I try to stick to vi not vim features as often working on systems where vim is not available; but admit that it's not exactly the same - sorry for my bad comment
      – Drako
      2 hours ago










    • I don't need to read that, as I already know about the black hole register, and that it is not essentially the same as a numbered register, it being essentially different in fact. I've given you a suggestion for making your answer better, to a question that definitely is about VIM, labelled as such in both tags and title. You've refused it. Don't be dismayed then if someone else comes along, reads my suggestion, and posts an answer giving the simple black hole register way of doing this that has no extra side-effects. I gave you the opportunity to make a good comprehensive answer.
      – JdeBP
      1 hour ago










    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Dread Boy is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477416%2fdelete-but-not-cut-a-line-in-vim%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    You're looking for the black hole register (:help quote_). If you prepend "_ to a delete command, the contents will just be gone. So, to delete and keep the next three words, and then get rid of the entire line, you'd use d3w"_dd.



    Advanced mapping



    That use case of keeping a part of the line while removing the complete line is a common one; I've written a set of mappings for that:



    "["x]dDD Delete the characters under the cursor until the end
    " of the line and [count]-1 more lines [into register x],
    " and delete the remainder of the line (i.e. the
    " characters before the cursor) and possibly following
    " empty line(s) without affecting a register.
    "["x]dDmotion Delete text that motion moves over [into register x]
    " and delete the remainder of the line(s) and possibly
    " following empty line(s) without affecting a register.
    "Visual["x],dD Delete the highlighted text [into register x] and delete
    " the remainder of the selected line(s) and possibly
    " following empty line(s) without affecting a register.
    function! s:DeleteCurrentAndFollowingEmptyLines()
    let l:currentLnum = line('.')
    let l:cnt = 1
    while l:currentLnum + l:cnt < line('$') && getline(l:currentLnum + l:cnt) =~# '^s*$'
    let l:cnt += 1
    endwhile

    return '"_' . l:cnt . 'dd'
    endfunction
    nnoremap <expr> <SID>(DeleteCurrentAndFollowingEmptyLines) <SID>DeleteCurrentAndFollowingEmptyLines()
    nnoremap <script> dDD D<SID>(DeleteCurrentAndFollowingEmptyLines)
    xnoremap <script> ,dD d<SID>(DeleteCurrentAndFollowingEmptyLines)
    function! s:DeleteCurrentAndFollowingEmptyLinesOperatorExpression()
    set opfunc=DeleteCurrentAndFollowingEmptyLinesOperator
    let l:keys = 'g@'

    if ! &l:modifiable || &l:readonly
    " Probe for "Cannot make changes" error and readonly warning via a no-op
    " dummy modification.
    " In the case of a nomodifiable buffer, Vim will abort the normal mode
    " command chain, discard the g@, and thus not invoke the operatorfunc.
    let l:keys = ":call setline('.', getline('.'))<CR>" . l:keys
    endif

    return l:keys
    endfunction
    function! DeleteCurrentAndFollowingEmptyLinesOperator( type )
    try
    " Note: Need to use an "inclusive" selection to make `] include the last
    " moved-over character.
    let l:save_selection = &selection
    set selection=inclusive

    execute 'silent normal! g`[' . (a:type ==# 'line' ? 'V' : 'v') . 'g`]"' . v:register . 'y'

    execute 'normal!' s:DeleteCurrentAndFollowingEmptyLines()
    finally
    if exists('l:save_selection')
    let &selection = l:save_selection
    endif
    endtry
    endfunction
    nnoremap <expr> dD <SID>DeleteCurrentAndFollowingEmptyLinesOperatorExpression()





    share|improve this answer
























      up vote
      2
      down vote













      You're looking for the black hole register (:help quote_). If you prepend "_ to a delete command, the contents will just be gone. So, to delete and keep the next three words, and then get rid of the entire line, you'd use d3w"_dd.



      Advanced mapping



      That use case of keeping a part of the line while removing the complete line is a common one; I've written a set of mappings for that:



      "["x]dDD Delete the characters under the cursor until the end
      " of the line and [count]-1 more lines [into register x],
      " and delete the remainder of the line (i.e. the
      " characters before the cursor) and possibly following
      " empty line(s) without affecting a register.
      "["x]dDmotion Delete text that motion moves over [into register x]
      " and delete the remainder of the line(s) and possibly
      " following empty line(s) without affecting a register.
      "Visual["x],dD Delete the highlighted text [into register x] and delete
      " the remainder of the selected line(s) and possibly
      " following empty line(s) without affecting a register.
      function! s:DeleteCurrentAndFollowingEmptyLines()
      let l:currentLnum = line('.')
      let l:cnt = 1
      while l:currentLnum + l:cnt < line('$') && getline(l:currentLnum + l:cnt) =~# '^s*$'
      let l:cnt += 1
      endwhile

      return '"_' . l:cnt . 'dd'
      endfunction
      nnoremap <expr> <SID>(DeleteCurrentAndFollowingEmptyLines) <SID>DeleteCurrentAndFollowingEmptyLines()
      nnoremap <script> dDD D<SID>(DeleteCurrentAndFollowingEmptyLines)
      xnoremap <script> ,dD d<SID>(DeleteCurrentAndFollowingEmptyLines)
      function! s:DeleteCurrentAndFollowingEmptyLinesOperatorExpression()
      set opfunc=DeleteCurrentAndFollowingEmptyLinesOperator
      let l:keys = 'g@'

      if ! &l:modifiable || &l:readonly
      " Probe for "Cannot make changes" error and readonly warning via a no-op
      " dummy modification.
      " In the case of a nomodifiable buffer, Vim will abort the normal mode
      " command chain, discard the g@, and thus not invoke the operatorfunc.
      let l:keys = ":call setline('.', getline('.'))<CR>" . l:keys
      endif

      return l:keys
      endfunction
      function! DeleteCurrentAndFollowingEmptyLinesOperator( type )
      try
      " Note: Need to use an "inclusive" selection to make `] include the last
      " moved-over character.
      let l:save_selection = &selection
      set selection=inclusive

      execute 'silent normal! g`[' . (a:type ==# 'line' ? 'V' : 'v') . 'g`]"' . v:register . 'y'

      execute 'normal!' s:DeleteCurrentAndFollowingEmptyLines()
      finally
      if exists('l:save_selection')
      let &selection = l:save_selection
      endif
      endtry
      endfunction
      nnoremap <expr> dD <SID>DeleteCurrentAndFollowingEmptyLinesOperatorExpression()





      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        You're looking for the black hole register (:help quote_). If you prepend "_ to a delete command, the contents will just be gone. So, to delete and keep the next three words, and then get rid of the entire line, you'd use d3w"_dd.



        Advanced mapping



        That use case of keeping a part of the line while removing the complete line is a common one; I've written a set of mappings for that:



        "["x]dDD Delete the characters under the cursor until the end
        " of the line and [count]-1 more lines [into register x],
        " and delete the remainder of the line (i.e. the
        " characters before the cursor) and possibly following
        " empty line(s) without affecting a register.
        "["x]dDmotion Delete text that motion moves over [into register x]
        " and delete the remainder of the line(s) and possibly
        " following empty line(s) without affecting a register.
        "Visual["x],dD Delete the highlighted text [into register x] and delete
        " the remainder of the selected line(s) and possibly
        " following empty line(s) without affecting a register.
        function! s:DeleteCurrentAndFollowingEmptyLines()
        let l:currentLnum = line('.')
        let l:cnt = 1
        while l:currentLnum + l:cnt < line('$') && getline(l:currentLnum + l:cnt) =~# '^s*$'
        let l:cnt += 1
        endwhile

        return '"_' . l:cnt . 'dd'
        endfunction
        nnoremap <expr> <SID>(DeleteCurrentAndFollowingEmptyLines) <SID>DeleteCurrentAndFollowingEmptyLines()
        nnoremap <script> dDD D<SID>(DeleteCurrentAndFollowingEmptyLines)
        xnoremap <script> ,dD d<SID>(DeleteCurrentAndFollowingEmptyLines)
        function! s:DeleteCurrentAndFollowingEmptyLinesOperatorExpression()
        set opfunc=DeleteCurrentAndFollowingEmptyLinesOperator
        let l:keys = 'g@'

        if ! &l:modifiable || &l:readonly
        " Probe for "Cannot make changes" error and readonly warning via a no-op
        " dummy modification.
        " In the case of a nomodifiable buffer, Vim will abort the normal mode
        " command chain, discard the g@, and thus not invoke the operatorfunc.
        let l:keys = ":call setline('.', getline('.'))<CR>" . l:keys
        endif

        return l:keys
        endfunction
        function! DeleteCurrentAndFollowingEmptyLinesOperator( type )
        try
        " Note: Need to use an "inclusive" selection to make `] include the last
        " moved-over character.
        let l:save_selection = &selection
        set selection=inclusive

        execute 'silent normal! g`[' . (a:type ==# 'line' ? 'V' : 'v') . 'g`]"' . v:register . 'y'

        execute 'normal!' s:DeleteCurrentAndFollowingEmptyLines()
        finally
        if exists('l:save_selection')
        let &selection = l:save_selection
        endif
        endtry
        endfunction
        nnoremap <expr> dD <SID>DeleteCurrentAndFollowingEmptyLinesOperatorExpression()





        share|improve this answer












        You're looking for the black hole register (:help quote_). If you prepend "_ to a delete command, the contents will just be gone. So, to delete and keep the next three words, and then get rid of the entire line, you'd use d3w"_dd.



        Advanced mapping



        That use case of keeping a part of the line while removing the complete line is a common one; I've written a set of mappings for that:



        "["x]dDD Delete the characters under the cursor until the end
        " of the line and [count]-1 more lines [into register x],
        " and delete the remainder of the line (i.e. the
        " characters before the cursor) and possibly following
        " empty line(s) without affecting a register.
        "["x]dDmotion Delete text that motion moves over [into register x]
        " and delete the remainder of the line(s) and possibly
        " following empty line(s) without affecting a register.
        "Visual["x],dD Delete the highlighted text [into register x] and delete
        " the remainder of the selected line(s) and possibly
        " following empty line(s) without affecting a register.
        function! s:DeleteCurrentAndFollowingEmptyLines()
        let l:currentLnum = line('.')
        let l:cnt = 1
        while l:currentLnum + l:cnt < line('$') && getline(l:currentLnum + l:cnt) =~# '^s*$'
        let l:cnt += 1
        endwhile

        return '"_' . l:cnt . 'dd'
        endfunction
        nnoremap <expr> <SID>(DeleteCurrentAndFollowingEmptyLines) <SID>DeleteCurrentAndFollowingEmptyLines()
        nnoremap <script> dDD D<SID>(DeleteCurrentAndFollowingEmptyLines)
        xnoremap <script> ,dD d<SID>(DeleteCurrentAndFollowingEmptyLines)
        function! s:DeleteCurrentAndFollowingEmptyLinesOperatorExpression()
        set opfunc=DeleteCurrentAndFollowingEmptyLinesOperator
        let l:keys = 'g@'

        if ! &l:modifiable || &l:readonly
        " Probe for "Cannot make changes" error and readonly warning via a no-op
        " dummy modification.
        " In the case of a nomodifiable buffer, Vim will abort the normal mode
        " command chain, discard the g@, and thus not invoke the operatorfunc.
        let l:keys = ":call setline('.', getline('.'))<CR>" . l:keys
        endif

        return l:keys
        endfunction
        function! DeleteCurrentAndFollowingEmptyLinesOperator( type )
        try
        " Note: Need to use an "inclusive" selection to make `] include the last
        " moved-over character.
        let l:save_selection = &selection
        set selection=inclusive

        execute 'silent normal! g`[' . (a:type ==# 'line' ? 'V' : 'v') . 'g`]"' . v:register . 'y'

        execute 'normal!' s:DeleteCurrentAndFollowingEmptyLines()
        finally
        if exists('l:save_selection')
        let &selection = l:save_selection
        endif
        endtry
        endfunction
        nnoremap <expr> dD <SID>DeleteCurrentAndFollowingEmptyLinesOperatorExpression()






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        Ingo Karkat

        8,26911731




        8,26911731






















            up vote
            1
            down vote













            you can copy that part that you want to use in named buffer and paste from there, for example:



            "ay3w


            this will yank 3 words in named buffer a
            and



            "ap


            would paste from named buffer a later; also you could first delete 3 words and then delete all line and later paste with



            "2p


            this would paste 2nd from last deletion from deletion buffer;
            also following suggestions on comments as this is VIM tagged question - there is native VIM solution for this (does not work on Vi):



            y3w then in new place "0p


            VIM has native feature to keep last yank in 0 registry.






            share|improve this answer






















            • Why not use VIM's black hole register?
              – JdeBP
              2 hours ago










            • @JdeBP are you serious? Did you even read the answer - second option in my answer is exactly that - I only did not name it black hole register - some what old style naming - deletion registry but essentially same thing numbered buffer from 1-9 keeping track of last changes in file
              – Drako
              2 hours ago











            • The second option in your answer is not the black hole register. The black hole register is not a numbered register.
              – JdeBP
              2 hours ago










            • @JdeBP read here: blog.dreasgrech.com/2010/06/vims-black-hole-register.html it seems that I have had partially wrong assumption that it the same, but essentially it's same with expanded functionality, that definitely is not needed here; also I try to stick to vi not vim features as often working on systems where vim is not available; but admit that it's not exactly the same - sorry for my bad comment
              – Drako
              2 hours ago










            • I don't need to read that, as I already know about the black hole register, and that it is not essentially the same as a numbered register, it being essentially different in fact. I've given you a suggestion for making your answer better, to a question that definitely is about VIM, labelled as such in both tags and title. You've refused it. Don't be dismayed then if someone else comes along, reads my suggestion, and posts an answer giving the simple black hole register way of doing this that has no extra side-effects. I gave you the opportunity to make a good comprehensive answer.
              – JdeBP
              1 hour ago














            up vote
            1
            down vote













            you can copy that part that you want to use in named buffer and paste from there, for example:



            "ay3w


            this will yank 3 words in named buffer a
            and



            "ap


            would paste from named buffer a later; also you could first delete 3 words and then delete all line and later paste with



            "2p


            this would paste 2nd from last deletion from deletion buffer;
            also following suggestions on comments as this is VIM tagged question - there is native VIM solution for this (does not work on Vi):



            y3w then in new place "0p


            VIM has native feature to keep last yank in 0 registry.






            share|improve this answer






















            • Why not use VIM's black hole register?
              – JdeBP
              2 hours ago










            • @JdeBP are you serious? Did you even read the answer - second option in my answer is exactly that - I only did not name it black hole register - some what old style naming - deletion registry but essentially same thing numbered buffer from 1-9 keeping track of last changes in file
              – Drako
              2 hours ago











            • The second option in your answer is not the black hole register. The black hole register is not a numbered register.
              – JdeBP
              2 hours ago










            • @JdeBP read here: blog.dreasgrech.com/2010/06/vims-black-hole-register.html it seems that I have had partially wrong assumption that it the same, but essentially it's same with expanded functionality, that definitely is not needed here; also I try to stick to vi not vim features as often working on systems where vim is not available; but admit that it's not exactly the same - sorry for my bad comment
              – Drako
              2 hours ago










            • I don't need to read that, as I already know about the black hole register, and that it is not essentially the same as a numbered register, it being essentially different in fact. I've given you a suggestion for making your answer better, to a question that definitely is about VIM, labelled as such in both tags and title. You've refused it. Don't be dismayed then if someone else comes along, reads my suggestion, and posts an answer giving the simple black hole register way of doing this that has no extra side-effects. I gave you the opportunity to make a good comprehensive answer.
              – JdeBP
              1 hour ago












            up vote
            1
            down vote










            up vote
            1
            down vote









            you can copy that part that you want to use in named buffer and paste from there, for example:



            "ay3w


            this will yank 3 words in named buffer a
            and



            "ap


            would paste from named buffer a later; also you could first delete 3 words and then delete all line and later paste with



            "2p


            this would paste 2nd from last deletion from deletion buffer;
            also following suggestions on comments as this is VIM tagged question - there is native VIM solution for this (does not work on Vi):



            y3w then in new place "0p


            VIM has native feature to keep last yank in 0 registry.






            share|improve this answer














            you can copy that part that you want to use in named buffer and paste from there, for example:



            "ay3w


            this will yank 3 words in named buffer a
            and



            "ap


            would paste from named buffer a later; also you could first delete 3 words and then delete all line and later paste with



            "2p


            this would paste 2nd from last deletion from deletion buffer;
            also following suggestions on comments as this is VIM tagged question - there is native VIM solution for this (does not work on Vi):



            y3w then in new place "0p


            VIM has native feature to keep last yank in 0 registry.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 19 mins ago

























            answered 3 hours ago









            Drako

            1113




            1113











            • Why not use VIM's black hole register?
              – JdeBP
              2 hours ago










            • @JdeBP are you serious? Did you even read the answer - second option in my answer is exactly that - I only did not name it black hole register - some what old style naming - deletion registry but essentially same thing numbered buffer from 1-9 keeping track of last changes in file
              – Drako
              2 hours ago











            • The second option in your answer is not the black hole register. The black hole register is not a numbered register.
              – JdeBP
              2 hours ago










            • @JdeBP read here: blog.dreasgrech.com/2010/06/vims-black-hole-register.html it seems that I have had partially wrong assumption that it the same, but essentially it's same with expanded functionality, that definitely is not needed here; also I try to stick to vi not vim features as often working on systems where vim is not available; but admit that it's not exactly the same - sorry for my bad comment
              – Drako
              2 hours ago










            • I don't need to read that, as I already know about the black hole register, and that it is not essentially the same as a numbered register, it being essentially different in fact. I've given you a suggestion for making your answer better, to a question that definitely is about VIM, labelled as such in both tags and title. You've refused it. Don't be dismayed then if someone else comes along, reads my suggestion, and posts an answer giving the simple black hole register way of doing this that has no extra side-effects. I gave you the opportunity to make a good comprehensive answer.
              – JdeBP
              1 hour ago
















            • Why not use VIM's black hole register?
              – JdeBP
              2 hours ago










            • @JdeBP are you serious? Did you even read the answer - second option in my answer is exactly that - I only did not name it black hole register - some what old style naming - deletion registry but essentially same thing numbered buffer from 1-9 keeping track of last changes in file
              – Drako
              2 hours ago











            • The second option in your answer is not the black hole register. The black hole register is not a numbered register.
              – JdeBP
              2 hours ago










            • @JdeBP read here: blog.dreasgrech.com/2010/06/vims-black-hole-register.html it seems that I have had partially wrong assumption that it the same, but essentially it's same with expanded functionality, that definitely is not needed here; also I try to stick to vi not vim features as often working on systems where vim is not available; but admit that it's not exactly the same - sorry for my bad comment
              – Drako
              2 hours ago










            • I don't need to read that, as I already know about the black hole register, and that it is not essentially the same as a numbered register, it being essentially different in fact. I've given you a suggestion for making your answer better, to a question that definitely is about VIM, labelled as such in both tags and title. You've refused it. Don't be dismayed then if someone else comes along, reads my suggestion, and posts an answer giving the simple black hole register way of doing this that has no extra side-effects. I gave you the opportunity to make a good comprehensive answer.
              – JdeBP
              1 hour ago















            Why not use VIM's black hole register?
            – JdeBP
            2 hours ago




            Why not use VIM's black hole register?
            – JdeBP
            2 hours ago












            @JdeBP are you serious? Did you even read the answer - second option in my answer is exactly that - I only did not name it black hole register - some what old style naming - deletion registry but essentially same thing numbered buffer from 1-9 keeping track of last changes in file
            – Drako
            2 hours ago





            @JdeBP are you serious? Did you even read the answer - second option in my answer is exactly that - I only did not name it black hole register - some what old style naming - deletion registry but essentially same thing numbered buffer from 1-9 keeping track of last changes in file
            – Drako
            2 hours ago













            The second option in your answer is not the black hole register. The black hole register is not a numbered register.
            – JdeBP
            2 hours ago




            The second option in your answer is not the black hole register. The black hole register is not a numbered register.
            – JdeBP
            2 hours ago












            @JdeBP read here: blog.dreasgrech.com/2010/06/vims-black-hole-register.html it seems that I have had partially wrong assumption that it the same, but essentially it's same with expanded functionality, that definitely is not needed here; also I try to stick to vi not vim features as often working on systems where vim is not available; but admit that it's not exactly the same - sorry for my bad comment
            – Drako
            2 hours ago




            @JdeBP read here: blog.dreasgrech.com/2010/06/vims-black-hole-register.html it seems that I have had partially wrong assumption that it the same, but essentially it's same with expanded functionality, that definitely is not needed here; also I try to stick to vi not vim features as often working on systems where vim is not available; but admit that it's not exactly the same - sorry for my bad comment
            – Drako
            2 hours ago












            I don't need to read that, as I already know about the black hole register, and that it is not essentially the same as a numbered register, it being essentially different in fact. I've given you a suggestion for making your answer better, to a question that definitely is about VIM, labelled as such in both tags and title. You've refused it. Don't be dismayed then if someone else comes along, reads my suggestion, and posts an answer giving the simple black hole register way of doing this that has no extra side-effects. I gave you the opportunity to make a good comprehensive answer.
            – JdeBP
            1 hour ago




            I don't need to read that, as I already know about the black hole register, and that it is not essentially the same as a numbered register, it being essentially different in fact. I've given you a suggestion for making your answer better, to a question that definitely is about VIM, labelled as such in both tags and title. You've refused it. Don't be dismayed then if someone else comes along, reads my suggestion, and posts an answer giving the simple black hole register way of doing this that has no extra side-effects. I gave you the opportunity to make a good comprehensive answer.
            – JdeBP
            1 hour ago










            Dread Boy is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            Dread Boy is a new contributor. Be nice, and check out our Code of Conduct.












            Dread Boy is a new contributor. Be nice, and check out our Code of Conduct.











            Dread Boy is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477416%2fdelete-but-not-cut-a-line-in-vim%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery