Wikia

Vim Tips Wiki

Display last viewed text lines at top of new shell

Talk0
1,610pages on
this wiki
Tip 1297 Printable Monobook Previous Next

created August 5, 2006 · complexity basic · author pulp · version n/a


function! s:Shell(...)
  let curline=line ('.')
  if curline < 6
    let start=0
  else
    let start=curline-5
  endif
  let end=curline+15
  execute 'silent !clear'
  execute 'silent !echo -e "\n...\n"'
  execute 'silent !sed ' . start . ',' . end . '\!d %'
  execute 'silent !echo -e "\n...\n"'
  execute 'shell'
endfunction
command! Shell call s:Shell()

Executing ":Shell" will start a new shell and display the last viewed text lines in the top of the new shell.

Useful if you read a 'README' file and you want to follow the install instruction ("./configurer, make etc).

With the displayed text you do not need to remember the commands.

CommentsEdit

This may be an alternative:

:nnoremap gsh :set t_te= t_ti=<CR>:sh<CR>:set t_te& t_ti&<CR>

Around Wikia's network

Random Wiki