svn - Vim -- paste content of command line process referencing filename of current buffer into new buffer -


i'm trying create mapping can svn compare-with-base few keystrokes

i know how each step manually....

  1. :new open new buffer.
  2. :read !svn cat <filename> read base version of file new buffer.
  3. :diffthis on new buffer , previous buffer diff files.

i'd love map series of events mapping -scb, not sure how grab filename (like :e %<cr>) , place read command. i'm not sure how can efficiently grab output of read command , put in new buffer if i'm using %.

as noted in comments, particular question has been asked , answered on superuser: https://superuser.com/questions/370125/getting-output-from-command-in-a-vim-buffer

for sake of general vim education, read on.

there @ least 3 ways access current file name. on command line,

:e! % 

will reload current file, although simpler use :e!. more useful example, using filename modifiers, edit foo.h if editing foo.c:

:sp %:r.h 

the second way use @% register, string variable name of current file (relative current directory).

:let myfile = @% :let mypath = fnamemodify(@%, ':p') 

the third way use expand():

:let myfile = expand("%") :let mypath = expand("%:p") 

there differences between fnamemodify() , expand().

:help cmdline-special :help @% :help @# :help fnamemodify() :help expand() 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -