Christian Brabandt wrote:

> On So, 04 Jun 2017, Kaartic Sivaraam wrote:
> 
> > Hello all,
> > 
> > I am currently using Vim 8.0. When I use vim as my preferred editor for
> > git. 
> > 
> > When I try to commit a change in git it open up vim to type the commit
> > message. Most of the time the text cursor seems to be positioned
> > somewhere in the middle of the commit template (the comments). As a
> > result, I am unable to type in the commit message directly after
> > switching to "insert" mode in vim. Any reasons for this misbehaviour ?
> > 
> > Environments:
> > Operating System: Debian GNU/Linux 9 (stretch)
> > Shell: bash
> 
> Perhaps, we should disable the last-position jump for commit messages in 
> general. Here is a patch:
> 
> diff --git a/runtime/defaults.vim b/runtime/defaults.vim
> index 6fd43db51..fdac666e6 100644
> --- a/runtime/defaults.vim
> +++ b/runtime/defaults.vim
> @@ -109,7 +109,7 @@ if has("autocmd")
>      " 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("$") |
> +      \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit' |
>        \   exe "normal! g`\"" |
>        \ endif
>  
> diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
> index a0cc971fe..b4b6bbfef 100644
> --- a/runtime/doc/eval.txt
> +++ b/runtime/doc/eval.txt
> @@ -5460,7 +5460,8 @@ line({expr})      The result is a Number, which is the 
> line number of the file
>  <                                                      *last-position-jump*
>                 This autocommand jumps to the last known position in a file
>                 just after opening it, if the '" mark is set: >
> -       :au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | 
> exe "normal! g`\"" | endif
> +       :au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") &&
> +            \ &ft !~# 'commit' | exe "normal! g`\"" | endif
>  
>  line2byte({lnum})                                      *line2byte()*
>                 Return the byte count from the start of the buffer for line

I suppose that this is better in most cases.  There might be some other
filetypes that only apply to temp files.

-- 
hundred-and-one symptoms of being an internet addict:
14. You start introducing yourself as "Jim at I-I-Net dot net dot au"

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to