{"action":"created","issue":{"url":"https://api.github.com/repos/jszakmeister/vim-togglecursor/issues/19","labels_url":"https://api.github.com/repos/jszakmeister/vim-togglecursor/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/jszakmeister/vim-togglecursor/issues/19/comments","events_url":"https://api.github.com/repos/jszakmeister/vim-togglecursor/issues/19/events","html_url":"https://github.com/jszakmeister/vim-togglecursor/issues/19","id":96577330,"number":19,"title":"[Bug] Vim cursor sometimes (always?) disappears on Vim startup when opening a file","user":{"login":"phongvcao","id":874795,"avatar_url":"https://avatars.githubusercontent.com/u/874795?v=3","gravatar_id":"","url":"https://api.github.com/users/phongvcao","html_url":"https://github.com/phongvcao","followers_url":"https://api.github.com/users/phongvcao/followers","following_url":"https://api.github.com/users/phongvcao/following{/other_user}","gists_url":"https://api.github.com/users/phongvcao/gists{/gist_id}","starred_url":"https://api.github.com/users/phongvcao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phongvcao/subscriptions","organizations_url":"https://api.github.com/users/phongvcao/orgs","repos_url":"https://api.github.com/users/phongvcao/repos","events_url":"https://api.github.com/users/phongvcao/events{/privacy}","received_events_url":"https://api.github.com/users/phongvcao/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-07-22T14:08:22Z","updated_at":"2015-08-11T16:59:56Z","closed_at":"2015-07-24T10:06:13Z","body":"For some reasons my cursor keeps disappearing if I open a file in Vim (using ```vim /path/to/file``` command) inside gnome-terminal with tmux and powerline. When I change my mouse focus from gnome-terminal to another window (I am using Vim under terminal), OR replace ```vim-togglecursor``` with this snippet of Vimscript inside my ```.vimrc```:\r\n\r\n```vim\r\n\" Toggle cursor between block and ibeam shape in different modes (Insert,\r\n\" Normal, Visual, Replace. Also make them blink.\r\nfunction! ToggleCursorByMode()\r\n    if exists('$TMUX')\r\n        if v:insertmode == 'r' || v:insertmode == 'v'\r\n            let &t_SI = \"\\<Esc>Ptmux;\\<Esc>\\e[3 q\\<Esc>\\\\\"\r\n        else\r\n            let &t_SI = \"\\<Esc>Ptmux;\\<Esc>\\e[5 q\\<Esc>\\\\\"\r\n        endif\r\n\r\n        let &t_EI = \"\\<Esc>Ptmux;\\<Esc>\\e[0 q\\<Esc>\\\\\"\r\n\r\n    else\r\n        if v:insertmode == 'r' || v:insertmode == 'v'\r\n            let &t_SI = \"\\e[3 q\"\r\n        else\r\n            let &t_SI = \"\\e[5 q\"\r\n        endif\r\n\r\n        let &t_EI = \"\\e[0 q\"\r\n    endif\r\nendfunction\r\n\r\ncall ToggleCursorByMode()\r\n\r\naugroup AutoCursor\r\n    autocmd InsertEnter * :call ToggleCursorByMode()\r\nautogroup END\r\n```\r\n\r\nEverything was working as expected. Without the above snippet of codes, sometimes even during cursor moving in Normal mode, my cursor disapearred and I had to move the mouse focus to another window beside gnome-terminal again and then move back.\r\n\r\nI believe there is currently a problem of ```autocmd VimEnter *``` statement in ```plugin/togglecursor.vim``` unable to load ```<SID>ToggleCursorInit()``` at Vim startup, because as long as I replaced ```vim-togglecursor``` with the above code, OR tried to move focus to another window (which triggered ```FocusGained``` & ```FocusLost```), the cursor started working again. So I guess you may want to add an ```autocmd BufWinEnter *``` OR invoking <SID>ToggleCursorInit() outside of autocmd (so it will be run when Vim sources the ```.vimrc``` file).\r\n\r\nHere is my version information:\r\nOS: Arch Linux\r\nShell: zsh 5.0.8\r\nMultiplexor: tmux 2.0\r\nVim: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul 11 2015 08:44:54)\r\nIncluded patches: 1-778\r\nGNOME: Version 3.16.2\r\n"},"comment":{"url":"https://api.github.com/repos/jszakmeister/vim-togglecursor/issues/comments/129968298","html_url":"https://github.com/jszakmeister/vim-togglecursor/issues/19#issuecomment-129968298","issue_url":"https://api.github.com/repos/jszakmeister/vim-togglecursor/issues/19","id":129968298,"user":{"login":"phphong","id":7910929,"avatar_url":"https://avatars.githubusercontent.com/u/7910929?v=3","gravatar_id":"","url":"https://api.github.com/users/phphong","html_url":"https://github.com/phphong","followers_url":"https://api.github.com/users/phphong/followers","following_url":"https://api.github.com/users/phphong/following{/other_user}","gists_url":"https://api.github.com/users/phphong/gists{/gist_id}","starred_url":"https://api.github.com/users/phphong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phphong/subscriptions","organizations_url":"https://api.github.com/users/phphong/orgs","repos_url":"https://api.github.com/users/phphong/repos","events_url":"https://api.github.com/users/phphong/events{/privacy}","received_events_url":"https://api.github.com/users/phphong/received_events","type":"User","site_admin":false},"created_at":"2015-08-11T16:59:56Z","updated_at":"2015-08-11T16:59:56Z","body":"My environment:\r\n* OS X Yosemite 10.10.3\r\n* Vim:\r\n  * VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug  1 2015 18:12:59)\r\n  * MacOS X (unix) version\r\n  * Included patches: 1-769\r\n  * Compiled by Homebrew\r\n  * Huge version with MacVim GUI\r\n* iTerm version: Build 2.9.20150626\r\n* I just use Vim directly, not through tmux\r\n\r\nI have tried all 3 types of cursor (underline, box, vertical bar) and in all 3 cases the cursor shape just remains the same when I enter Vim"}}