Assuming you mean the Vim command line:
(if you mean the OS command line, see below).
For parts of strings (i.e. end of line character) you can do something like this:
" Visually select lines, then: y:<CR>"<ENTER>
where <CR> means pressing Ctrl + R. y 'yanks' selected text : goes into command mode, <CR>" extracts the contents of the register " (the last yanked text) on the command line and <ENTER> (obviously) executes the command.
If you want to do linear things, it's a little more complicated (since the command line doesn't like ^M ). I would recommend something like this in your vimrc:
function! RunCommands() exe getline('.') endfunction command -range RunCommands <line1>,<line2>call RunCommands() vmap ,r :RunCommands<CR>
Select the lines (after restarting vim) and press ,r .
Another way that may be useful is to copy the necessary lines, press q: to open a command prompt window and paste the necessary lines there, and then move the cursor over the desired line and press ENTER . This has the advantage that you can edit the command before pressing ENTER . He will only run one command at a time.
If you mean (for example) the Windows or Linux command line:
Use the function above, but instead:
exe getline('.')
using
call system(getline('.'))
or, if you want to see the result:
echo system(getline('.'))
or
echomsg system(getline('.'))
For more information:
:help :echo :help :echomsg :help :messages :help :vmap :help :command-range :help :command :help :function :help c_CTRL-R :help :exe :help getline() :help system()