mirror of
https://github.com/mhinz/vim-galore.git
synced 2025-02-24 01:59:28 +08:00
Usage: restore cursor position when opening file
This commit is contained in:
parent
bb66b9a3cb
commit
bd8a709119
@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Basics: [Marks?](README.md#marks)
|
- Basics: [Marks?](README.md#marks)
|
||||||
- Tips: [Saner command-line history](README.md#saner-command-line-history)
|
- Tips: [Saner command-line history](README.md#saner-command-line-history)
|
||||||
- Usage: [Editing remote files](README.md#editing-remote-files)
|
- Usage: [Editing remote files](README.md#editing-remote-files)
|
||||||
|
- Usage: [Restore cursor position when opening file](#restore-cursor-position-when-opening-file)
|
||||||
- Debugging: [Verbosity](README.md#verbosity)
|
- Debugging: [Verbosity](README.md#verbosity)
|
||||||
- Debugging: [Debugging Vim scripts](README.md#debugging-vim-scripts)
|
- Debugging: [Debugging Vim scripts](README.md#debugging-vim-scripts)
|
||||||
- Debugging: [Debugging syntax files](README.md#debugging-syntax-files)
|
- Debugging: [Debugging syntax files](README.md#debugging-syntax-files)
|
||||||
|
19
README.md
19
README.md
@ -30,6 +30,7 @@ added every day. Things about to be added can be found here:
|
|||||||
- [Clipboard theory (Windows, OSX)](#clipboard-theory-windows-osx)
|
- [Clipboard theory (Windows, OSX)](#clipboard-theory-windows-osx)
|
||||||
- [Clipboard theory (Linux, BSD, ...)](#clipboard-theory-linux-bsd-)
|
- [Clipboard theory (Linux, BSD, ...)](#clipboard-theory-linux-bsd-)
|
||||||
- [Clipboard usage](#clipboard-usage)
|
- [Clipboard usage](#clipboard-usage)
|
||||||
|
- [Restore cursor position when opening file](#restore-cursor-position-when-opening-file)
|
||||||
- [Editing remote files](#editing-remote-files)
|
- [Editing remote files](#editing-remote-files)
|
||||||
- [Managing plugins](#managing-plugins)
|
- [Managing plugins](#managing-plugins)
|
||||||
- [Block insert](#block-insert)
|
- [Block insert](#block-insert)
|
||||||
@ -636,6 +637,24 @@ Vim comes with a pretty extensive documentation:
|
|||||||
:h gui-clipboard
|
:h gui-clipboard
|
||||||
:h gui-selections
|
:h gui-selections
|
||||||
```
|
```
|
||||||
|
#### Restore cursor position when opening file
|
||||||
|
|
||||||
|
Without this, you will always be at line 1 when opening a file. With this, you
|
||||||
|
will be at the position where you left off.
|
||||||
|
|
||||||
|
Put this in your vimrc:
|
||||||
|
```viml
|
||||||
|
autocmd BufReadPost *
|
||||||
|
\ if line("'\"") > 1 && line("'\"") <= line("$") |
|
||||||
|
\ exe "normal! g`\"" |
|
||||||
|
\ endif
|
||||||
|
```
|
||||||
|
|
||||||
|
This simpy does `` g`" `` (jump to position where you left off without changing
|
||||||
|
jumplist) if that position still exists (the file might have fewer lines since
|
||||||
|
it was altered by another program).
|
||||||
|
|
||||||
|
This requires the use of a viminfo file: `:h viminfo-'`.
|
||||||
|
|
||||||
#### Editing remote files
|
#### Editing remote files
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user