mirror of
https://github.com/amix/vimrc
synced 2024-12-12 05:02:30 +00:00
Added vim-lastplace
This commit is contained in:
parent
3aefdbd21a
commit
96e10ed101
5 changed files with 244 additions and 0 deletions
1
sources_non_forked/vim-lastplace/.gitignore
vendored
Normal file
1
sources_non_forked/vim-lastplace/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
doc/tags
|
22
sources_non_forked/vim-lastplace/LICENSE
Normal file
22
sources_non_forked/vim-lastplace/LICENSE
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015 - 2017 Greg Dietsche
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
105
sources_non_forked/vim-lastplace/README.md
Normal file
105
sources_non_forked/vim-lastplace/README.md
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
# vim-lastplace v3.1.1
|
||||||
|
|
||||||
|
Intelligently reopen files at your last edit position. By default git,
|
||||||
|
svn, and mercurial commit messages are ignored because you
|
||||||
|
probably want to type a new message and not re-edit the previous
|
||||||
|
one.
|
||||||
|
|
||||||
|
## Advantages
|
||||||
|
Advantages over the snippets that can be found around the net include:
|
||||||
|
* Commit messages automatically start at the beginning of a file. This is important because many version control systems re-use the same file for commit message editing.
|
||||||
|
* Maximizes Available Context
|
||||||
|
- Center the cursor vertically after restoring last edit position.
|
||||||
|
- Keep as much of the file on screen as possible when last edit position is at the end of the file.
|
||||||
|
* Opens folds if the last edit position is inside a fold.
|
||||||
|
* Works properly with new file templates and scripts that jump to a specific line in them.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
You can use [pathogen.vim](https://github.com/tpope/vim-pathogen) or other plugin managers to install and use vim-lastplace.
|
||||||
|
|
||||||
|
cd ~/.vim/bundle
|
||||||
|
git clone git://github.com/farmergreg/vim-lastplace.git
|
||||||
|
|
||||||
|
Depending on which Vim package you're using, Vim may be preconfigured with
|
||||||
|
last-edit-position logic that doesn't work quite as well as vim-lastplace.
|
||||||
|
If so, you may want to disable that in favor of vim-lastplace. For example,
|
||||||
|
for Vim as packaged with Git for Windows, you can edit
|
||||||
|
`C:\Program Files\Git\etc\vimrc` and comment out the "Remember positions in files"
|
||||||
|
`autocmd BufReadPost *` block.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
You can configure what file types to ignore by setting
|
||||||
|
g:lastplace_ignore in your vimrc. This is a comma separated list.
|
||||||
|
By default it is set to:
|
||||||
|
|
||||||
|
let g:lastplace_ignore = "gitcommit,gitrebase,svn,hgcommit"
|
||||||
|
|
||||||
|
You can configure buffer types to ignore by setting
|
||||||
|
g:lastplace_ignore_buftype in your vimrc. This is a comma separated list.
|
||||||
|
By default it is set to:
|
||||||
|
|
||||||
|
let g:lastplace_ignore_buftype = "quickfix,nofile,help"
|
||||||
|
|
||||||
|
Folds are automatically opened when jumping to the last edit position. If you
|
||||||
|
do not like this behavior you can disable it by putting this in your vimrc:
|
||||||
|
|
||||||
|
let g:lastplace_open_folds = 0
|
||||||
|
|
||||||
|
## Miscellaneous
|
||||||
|
This plugin is complete and stable. Please do not be afraid to try it even
|
||||||
|
if there is very little recent activity in this repository. If you do find
|
||||||
|
a bug, please submit a pull request that fixes whatever problem you're having.
|
||||||
|
|
||||||
|
## Version History
|
||||||
|
vim-lastplace uses [semver](http://semver.org/) to manage version numbers.
|
||||||
|
|
||||||
|
### 3.1.1
|
||||||
|
- Add 'nofile' and 'help' to lastplace_ignore_buftype. (Issue [#14](https://github.com/farmergreg/vim-lastplace/issues/14))
|
||||||
|
- Do not jump when a new file is created (Issue [#15](https://github.com/farmergreg/vim-lastplace/issues/15), [#16](https://github.com/farmergreg/vim-lastplace/issues/16))
|
||||||
|
|
||||||
|
### 3.1.0
|
||||||
|
- Add g:lastplace_ignore_buftype setting.
|
||||||
|
- Update github links from username dietsche to farmergreg.
|
||||||
|
|
||||||
|
### 3.0.4
|
||||||
|
- Add g:lastplace_open_folds option.
|
||||||
|
|
||||||
|
### 3.0.3
|
||||||
|
- Point release for Debian packaging. Changes all http links to https. No code changes.
|
||||||
|
|
||||||
|
### 3.0.2
|
||||||
|
- A fix for files that are smaller than the current screen size (issue #8)
|
||||||
|
|
||||||
|
### 3.0.1
|
||||||
|
- A fix for files with modelines.
|
||||||
|
|
||||||
|
### 3.0.0
|
||||||
|
|
||||||
|
- Open folds if the last edited area is inside a closed fold.
|
||||||
|
|
||||||
|
### 2.0.1
|
||||||
|
|
||||||
|
- Add gitrebase filetype to the ignore list.
|
||||||
|
|
||||||
|
### 2.0.0
|
||||||
|
|
||||||
|
- Center the screen when restoring the cursor position.
|
||||||
|
- When at the end of a file, keep as much of it on screen as possible.
|
||||||
|
|
||||||
|
### 1.0.0
|
||||||
|
|
||||||
|
- Initial version.
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
- Author : Gregory L. Dietsche
|
||||||
|
- Web Page: https://www.gregd.org/
|
||||||
|
|
||||||
|
Get the latest version, submit pull requests, and file bug reports
|
||||||
|
on GitHub:
|
||||||
|
- https://github.com/farmergreg/vim-lastplace
|
||||||
|
|
||||||
|
If you like this plugin, please star and rate it on these sites:
|
||||||
|
|
||||||
|
- [GitHub](https://github.com/farmergreg/vim-lastplace)
|
||||||
|
- [Vim.org](http://www.vim.org/scripts/script.php?script_id=5090)
|
36
sources_non_forked/vim-lastplace/doc/vim-lastplace.txt
Normal file
36
sources_non_forked/vim-lastplace/doc/vim-lastplace.txt
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
*vim-lastplace* Intelligently reopen files where you left off.
|
||||||
|
|
||||||
|
Author: Gregory L. Dietsche <https://www.gregd.org/>
|
||||||
|
License: MIT
|
||||||
|
Version: 3.1.1
|
||||||
|
|
||||||
|
INTRODUCTION *vim-lastplace-introduction*
|
||||||
|
|
||||||
|
Intelligently reopen files where you left off. By default git,
|
||||||
|
svn, and mercurial commit messages are ignored because you
|
||||||
|
probably want to type a new message and not re-edit the previous
|
||||||
|
one.
|
||||||
|
|
||||||
|
You can configure what file types to ignore by setting
|
||||||
|
g:lastplace_ignore in your vimrc. This is a comma separated list.
|
||||||
|
By default it is set to:
|
||||||
|
|
||||||
|
let g:lastplace_ignore = "gitcommit,gitrebase,svn,hgcommit"
|
||||||
|
|
||||||
|
You can configure buffer types to ignore by setting
|
||||||
|
g:lastplace_ignore_buftype in your vimrc. This is a comma separated list.
|
||||||
|
By default it is set to:
|
||||||
|
|
||||||
|
let g:lastplace_ignore_buftype = "quickfix,nofile,help"
|
||||||
|
|
||||||
|
Folds are automatically opened when jumping to the last edit position. If you
|
||||||
|
do not like this behavior you can disable it by putting this in your vimrc:
|
||||||
|
|
||||||
|
let g:lastplace_open_folds = 0
|
||||||
|
|
||||||
|
ABOUT *vim-lastplace-about*
|
||||||
|
|
||||||
|
Get the latest version and/or report a bug on GitHub:
|
||||||
|
https://github.com/farmergreg/vim-lastplace
|
||||||
|
|
||||||
|
vim:tw=78:et:ft=help:norl:
|
80
sources_non_forked/vim-lastplace/plugin/vim-lastplace.vim
Normal file
80
sources_non_forked/vim-lastplace/plugin/vim-lastplace.vim
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
" ============================================================================
|
||||||
|
" File: vim-lastplace.vim
|
||||||
|
" Description: Reopen files where you left off. Configurable.
|
||||||
|
" Author: Gregory L. Dietsche <vim@gregd.org>
|
||||||
|
" Licence: MIT
|
||||||
|
" Website: https://www.gregd.org/
|
||||||
|
" Version: 3.1.1
|
||||||
|
" ============================================================================
|
||||||
|
|
||||||
|
if exists("b:loaded_lastplace_plugin") || &cp
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:loaded_lastplace_plugin = 1
|
||||||
|
|
||||||
|
scriptencoding utf-8
|
||||||
|
|
||||||
|
if !exists('g:lastplace_ignore')
|
||||||
|
let g:lastplace_ignore = "gitcommit,gitrebase,svn,hgcommit"
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !exists('g:lastplace_open_folds')
|
||||||
|
let g:lastplace_open_folds = 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !exists('g:lastplace_ignore_buftype')
|
||||||
|
let g:lastplace_ignore_buftype = "quickfix,nofile,help"
|
||||||
|
endif
|
||||||
|
|
||||||
|
fu! s:lastplace()
|
||||||
|
if index(split(g:lastplace_ignore_buftype, ","), &buftype) != -1
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
if index(split(g:lastplace_ignore, ","), &filetype) != -1
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
try
|
||||||
|
"if the file does not exist on disk (a new, unsaved file) then do nothing
|
||||||
|
if empty(glob(@%))
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
catch
|
||||||
|
return
|
||||||
|
endtry
|
||||||
|
|
||||||
|
if line("'\"") > 0 && line("'\"") <= line("$")
|
||||||
|
"if the last edit position is set and is less than the
|
||||||
|
"number of lines in this buffer.
|
||||||
|
|
||||||
|
if line("w$") == line("$")
|
||||||
|
"if the last line in the current buffer is
|
||||||
|
"also the last line visible in this window
|
||||||
|
execute "normal! g`\""
|
||||||
|
|
||||||
|
elseif line("$") - line("'\"") > ((line("w$") - line("w0")) / 2) - 1
|
||||||
|
"if we're not at the bottom of the file, center the
|
||||||
|
"cursor on the screen after we make the jump
|
||||||
|
execute "normal! g`\"zz"
|
||||||
|
|
||||||
|
else
|
||||||
|
"otherwise, show as much context as we can by jumping
|
||||||
|
"to the end of the file and then to the mark. If we
|
||||||
|
"pressed zz here, there would be blank lines at the
|
||||||
|
"bottom of the screen. We intentionally leave the
|
||||||
|
"last line blank by pressing <c-e> so the user has a
|
||||||
|
"clue that they are near the end of the file.
|
||||||
|
execute "normal! \G'\"\<c-e>"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if foldclosed(".") != -1 && g:lastplace_open_folds
|
||||||
|
"if we're in a fold, make the current line visible and recenter screen
|
||||||
|
execute "normal! zvzz"
|
||||||
|
endif
|
||||||
|
endf
|
||||||
|
|
||||||
|
augroup lastplace_plugin
|
||||||
|
autocmd!
|
||||||
|
autocmd BufWinEnter * call s:lastplace()
|
||||||
|
augroup END
|
Loading…
Reference in a new issue