Skip to content

Commit

Permalink
Add :RunLine vim function
Browse files Browse the repository at this point in the history
It inserts the output of a command. Super useful for blog posts!
  • Loading branch information
gabebw committed Mar 27, 2015
1 parent 5f216ac commit 2163f6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions vim/functions/run_line.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
" Given your cursor is on a line like this:
"
" $ echo Hello
"
" This command strips off the dollar sign and puts the result of that command on
" the lines below.
function! RunLine()
let command = substitute(getline('.'), "^\\$ \\?", "", "")
let g:result = system(command)
for line in reverse(split(g:result, "\n"))
call append(".", line)
endfor
endfunction

command! RunLine call RunLine()
1 change: 1 addition & 0 deletions vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let mapleader=" "

" Source the rest of the configuration
call s:SourceConfigFilesIn('')
call s:SourceConfigFilesIn('functions')
call s:SourceConfigFilesIn('rcplugins') " after Vundle loads

" Turn on syntax highlighting and filetype detection.
Expand Down

0 comments on commit 2163f6e

Please sign in to comment.