VIM Script Reference Sheet
VIM DOC: http://vimdoc.sourceforge.net/htmldoc/
Path to Current Buffer
Show Current Buffer File
File Full Path of current buffer:
:echo expand("%:p")
/home/tux/Downloads/test.sh
Full path to directory containing the file
:echo expand("%:p:h")
/home/tux/Downloads
Example:
nmap <F10> :echo expand('%p:h') <CR>
Insert Current Buffer File Path at cursor position
:put = expand('%:p')
:put = expand('%:p:h')
Pipe Shell Command to New Buffer
The charcater (#) is replaced by the current file name
:new | r ! <shell command>
:new | r ! <shell command> #
Example:
:new | r ! git log
:new | r ! file #
Set Map Keys
nmap <F10> :clist<CR>
nmap <F11> :cprev<CR>
nmap <F12> :cnext<CR>
Useful Commands
Create Commands
It will show the current date in the consolee
:command! Today :echo stftime("%c")
:Today
Current Date
Insert current date in current buffer
function! InsertDate ()
let Today = system("date")
:put = Today
endfunction
:call InsertDate()
Dom Mai 31 21:10:35 BRT 2015