Vim Tips Wiki

Display last viewed text lines at top of new shell

1,625pages on
this wiki
Add New Page
Talk0 Share
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
    let start=curline-5
  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'
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.


This may be an alternative:

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

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.