dblume commited on 2024-03-15 10:56:40
Showing 2 changed files, with 8 additions and 4 deletions.
At one time &filetype was set in BufReadPost, but not now. Fix is to use a FileType autocmd for gitcommit. If it were more complicated, could put in [after/]ftplugin/$FILETYPE.vim per https://www.reddit.com/r/vim/comments/k1c63f/should_the_filetype_option_be_set_by_the_time_the/
| ... | ... |
@@ -274,11 +274,13 @@ if has("autocmd")
|
| 274 | 274 |
autocmd BufRead README set wrap linebreak " "soft" wrap of existing lines |
| 275 | 275 |
autocmd BufRead *.rs :setlocal tags=./rusty-tags.vi;/ |
| 276 | 276 |
|
| 277 |
- " When editing a file, always jump to the last cursor position |
|
| 277 |
+ " When editing a file, always jump to the last cursor position... |
|
| 278 | 278 |
autocmd BufReadPost * |
| 279 |
- \ if &ft != "p4changelist" && &ft != "gitcommit" && line("'\"") > 0 && line ("'\"") <= line("$") |
|
|
| 279 |
+ \ if line("'\"") > 0 && line ("'\"") <= line("$") |
|
|
| 280 | 280 |
\ exe "normal! g'\"" | |
| 281 | 281 |
\ endif |
| 282 |
+ " ...except for gitcommit where we always want to start at the top |
|
| 283 |
+ autocmd FileType gitcommit exe "normal! gg" |
|
| 282 | 284 |
|
| 283 | 285 |
autocmd BufNewFile,BufReadPost * let b:git_branch = GitBranch() |
| 284 | 286 |
autocmd BufEnter * let b:git_branch = GitBranch() |
| ... | ... |
@@ -303,11 +303,13 @@ if has("autocmd")
|
| 303 | 303 |
autocmd BufRead README set wrap linebreak " "soft" wrap of existing lines |
| 304 | 304 |
autocmd BufRead *.rs :setlocal tags=./rusty-tags.vi;/ |
| 305 | 305 |
|
| 306 |
- " When editing a file, always jump to the last cursor position |
|
| 306 |
+ " When editing a file, always jump to the last cursor position... |
|
| 307 | 307 |
autocmd BufReadPost * |
| 308 |
- \ if &ft != "p4changelist" && &ft != "gitcommit" && line("'\"") > 0 && line ("'\"") <= line("$") |
|
|
| 308 |
+ \ if line("'\"") > 0 && line ("'\"") <= line("$") |
|
|
| 309 | 309 |
\ exe "normal! g'\"" | |
| 310 | 310 |
\ endif |
| 311 |
+ " ...except for gitcommit where we always want to start at the top |
|
| 312 |
+ autocmd FileType gitcommit exe "normal! gg" |
|
| 311 | 313 |
|
| 312 | 314 |
autocmd BufNewFile,BufReadPost * let b:git_branch = GitBranch() |
| 313 | 315 |
autocmd BufEnter * let b:git_branch = GitBranch() |
| 314 | 316 |