About: Open the last edited file   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

With this in vimrc, invoking Vim without arguments will open the last file (it will get the last file and position from .viminfo). " Go to last file if invoked without arguments. autocmd VimEnter * nested if \ argc() == 0 && \ bufname("%") == "" && \ bufname("2" + 0) != "" | \ exe "normal! `0" | \ endif " From vimrc_example.vim distributed with Vim 7. " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif

AttributesValues
rdfs:label
  • Open the last edited file
rdfs:comment
  • With this in vimrc, invoking Vim without arguments will open the last file (it will get the last file and position from .viminfo). " Go to last file if invoked without arguments. autocmd VimEnter * nested if \ argc() == 0 && \ bufname("%") == "" && \ bufname("2" + 0) != "" | \ exe "normal! `0" | \ endif " From vimrc_example.vim distributed with Vim 7. " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif
Version
  • 6(xsd:integer)
dbkwik:vim/property/wikiPageUsesTemplate
Previous
  • 610(xsd:integer)
Author
  • Adam Monsen
Complexity
  • basic
Created
  • 2003(xsd:integer)
ID
  • 613(xsd:integer)
NEXT
  • 614(xsd:integer)
Rating
  • 9(xsd:integer)
abstract
  • With this in vimrc, invoking Vim without arguments will open the last file (it will get the last file and position from .viminfo). " Go to last file if invoked without arguments. autocmd VimEnter * nested if \ argc() == 0 && \ bufname("%") == "" && \ bufname("2" + 0) != "" | \ exe "normal! `0" | \ endif " From vimrc_example.vim distributed with Vim 7. " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif TO DO In the above, bufname("2" + 0) is a confused way of saying bufname(2). But what has buffer 2 got to do with it? These make sure all your tabs are restored (VIM 7.x and higher). " Open last active file(s) if VIM is invoked without arguments. autocmd VimLeave * nested let buffernr = bufnr("$") | \ let buflist = [] | \ while buffernr > 0 | \ if buflisted(buffernr) | \ let buflist += [ bufname(buffernr) ] | \ endif | \ let buffernr -= 1 | \ endwhile | \ if (!isdirectory($HOME . "/.vim")) | \ call mkdir($HOME . "/.vim") | \ endif | \ call writefile(reverse(buflist), $HOME . "/.vim/buflist.txt") autocmd VimEnter * nested if argc() == 0 && filereadable($HOME . "/.vim/buflist.txt") | \ for line in readfile($HOME . "/.vim/buflist.txt") | \ if filereadable(line) | \ execute "tabedit " . line | \ set bufhidden=delete | \ endif | \ endfor | \ tabclose 1 | \ endif Am I missing something? Why can't you just use :mksession? [ help :mksession] --Fritzophrenic 02:00, 6 April 2009 (UTC) You are right. This works better. " Go to last file(s) if invoked without arguments. autocmd VimLeave * nested if (!isdirectory($HOME . "/.vim")) | \ call mkdir($HOME . "/.vim") | \ endif | \ execute "mksession! " . $HOME . "/.vim/Session.vim" autocmd VimEnter * nested if argc() == 0 && filereadable($HOME . "/.vim/Session.vim") | \ execute "source " . $HOME . "/.vim/Session.vim"
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software