Reputation: 125
Summary:
let @c = "dd/##completed <CR> p"
Is not working, any suggestions?
I have recorded a macro which deletes a line, moves to another line (my ##completed section)and pastes the line to here.
This was working fine until I realised that the mark ('c - which directs to my ##completed section) does not stick to the text, but to the line itself (obvious now I think of it).
So instead I have altered my .vimrc to perform a search for the line ##completed and paste the contents below it.
The code is as follows...
let @c = "dd/completed <CR> p"
But this does not work, instead I am presented with "/completed p" inside my command line . So it seems that the vimrc is not processing the carriage return correctly, do I have the syntax wrong here?
Or if this is a terrible way of moving lines around, can anyone offer a better alternative?
Upvotes: 1
Views: 91
Reputation: 172580
I don't fully understand your mapping, but you need to write \<CR>
inside double quotes to get a carriage return; the backslash is missing. Alternatively, you can directly insert it via Ctrl + V (or Q on many Windows installations), followed by Enter.
Generally, I wouldn't preset a register (c
, what you mistakenly refer to as "mark") in your .vimrc; if you need this often, define a mapping via :nnoremap
. You can assign mappings to any free key sequence (and with <Leader>
; i.e. backslash, you have a free starting key), but you only have 26 named registers.
For moving text, look into the :move
command. This might do what you want:
:move /##completed
Upvotes: 4