Loading ...
Sorry, an error occurred while loading the content.

Re: python shortcut issue

Expand Messages
  • peiman khosravi
    I think I came up with a solution. Made a file called pythonft.vim in ftdetect/ with this content: au BufNewFile,BufRead *.py set filetype=python au
    Message 1 of 6 , May 11, 2013
    • 0 Attachment
      I think I came up with a solution. 

      Made a file called 'pythonft.vim' in ftdetect/ with this content:

      au BufNewFile,BufRead *.py set filetype=python
      au BufNewFile,BufRead *.py so ~/.vim/macros/python_macros.vim

      I then defined the shortcut in python_macros.vim:

      map <buffer> π :w <CR>:!python % <CR>

      It seems to be working now.

      Thanks
      Peiman 




      On 11 May 2013 10:39, peiman khosravi <peimankhosravi@...> wrote:
      Hello, 

      Thanks for the reply. I tried your suggestion but it doesn't seem to make a difference. I've pasted the content of my .vimrc file below.

      Thanks
      Peiman


      " Configuration file for vim
      set modelines=0         " CVE-2007-2438

      " Normally we use vim-extensions. If you want true vi-compatibility
      " remove change the following statements
      set nocompatible        " Use Vim defaults instead of 100% vi compatibility
      set backspace=2         " more powerful backspacing

      " Don't write backup file if vim is being called by "crontab -e"
      au BufWrite /private/tmp/crontab.* set nowritebackup
      " Don't write backup file if vim is being called by "chpass"
      au BufWrite /private/etc/pw.* set nowritebackup

      set ai                  " auto indenting
      set history=100         " keep 100 lines of history
      set ruler               " show the cursor position
      syntax on               " syntax highlighting
      set hlsearch            " highlight the last searched term
      filetype plugin on      " use the file type plugins
      set nofoldenable
      colorscheme murphy

      map <buffer> π :w <CR>:!python % <CR>
          if exists('*<SID>Python_jump') | finish | endif

      " When editing a file, always jump to the last cursor position
      " autocmd BufReadPost *
      " \ if ! exists("g:leave_my_cursor_position_alone") |
      " \ if line("'\"") > 0 && line ("'\"") <= line("$") |
      " \ exe "normal g'\"" |
      " \ endif |
      " \ endif
      "







      www.peimankhosravi.co.uk || Subscribe to RSS Feed

      To receive emails about upcoming concerts visit this page & enter your email address in the 'follow' section.



      On 10 May 2013 09:39, huubby zhou <huubby1@...> wrote:
      I guess you add the map at the end of python.vim, is that correct?

      If so, I suggest you move your map command to before
         if exists('*<SID>Python_jump') | finish | endif

      If no, please give your python.vim.


      On Thu, May 9, 2013 at 8:35 PM, peiman khosravi <peimankhosravi@...> wrote:
      Hello, 

      I'm experiencing something odd. Is it a bug or my lack of knowledge?

      I open a new window (cmnd-n). I type ':e python.py' and paste a bit of code in there, which I have copied from another document. The syntax is highlighted and all is good. 

      I then press alt-p, which is a shortcut I have defined in my /vim/plugin/python.vim file ("map <buffer> π :w <CR>:!python % <CR>"). 

      Result: Nothing happens. 

      I save the file and try again: nothing happens.

      I reopen the file, and the shortcut is now working. Am I doing something wrong?

      Many Thanks
      Peiman   

      --
      --
      You received this message from the "vim_mac" 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_mac" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
       
       

      --
      --
      You received this message from the "vim_mac" 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_mac" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
       
       


      --
      --
      You received this message from the "vim_mac" 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_mac" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
       
       
    • huubby zhou
      Well, it s kind of not what I mean. I thought you said you put the map π :w :!python % in your python.vim that underneath system vim
      Message 2 of 6 , May 11, 2013
      • 0 Attachment
        Well, it's kind of not what I mean. I thought you said you put the 
            map <buffer> π :w <CR>:!python % <CR>
        in your python.vim that underneath system vim directory, turns out I'm
        wrong, sorry for the confusing.

        I think your problem is the '<buffer>', remove that then you should be
        fine. 
            
            map <buffer> π :w <CR>:!python % <CR>
        This map command means, you want the mapping only works in current
        buffer locally. ":h map-<buffer>" if you want further details.




        On Sat, May 11, 2013 at 6:09 PM, peiman khosravi <peimankhosravi@...> wrote:
        I think I came up with a solution. 

        Made a file called 'pythonft.vim' in ftdetect/ with this content:

        au BufNewFile,BufRead *.py set filetype=python
        au BufNewFile,BufRead *.py so ~/.vim/macros/python_macros.vim

        I then defined the shortcut in python_macros.vim:

        map <buffer> π :w <CR>:!python % <CR>

        It seems to be working now.

        Thanks
        Peiman 




        On 11 May 2013 10:39, peiman khosravi <peimankhosravi@...> wrote:
        Hello, 

        Thanks for the reply. I tried your suggestion but it doesn't seem to make a difference. I've pasted the content of my .vimrc file below.

        Thanks
        Peiman


        " Configuration file for vim
        set modelines=0         " CVE-2007-2438

        " Normally we use vim-extensions. If you want true vi-compatibility
        " remove change the following statements
        set nocompatible        " Use Vim defaults instead of 100% vi compatibility
        set backspace=2         " more powerful backspacing

        " Don't write backup file if vim is being called by "crontab -e"
        au BufWrite /private/tmp/crontab.* set nowritebackup
        " Don't write backup file if vim is being called by "chpass"
        au BufWrite /private/etc/pw.* set nowritebackup

        set ai                  " auto indenting
        set history=100         " keep 100 lines of history
        set ruler               " show the cursor position
        syntax on               " syntax highlighting
        set hlsearch            " highlight the last searched term
        filetype plugin on      " use the file type plugins
        set nofoldenable
        colorscheme murphy

        map <buffer> π :w <CR>:!python % <CR>
            if exists('*<SID>Python_jump') | finish | endif

        " When editing a file, always jump to the last cursor position
        " autocmd BufReadPost *
        " \ if ! exists("g:leave_my_cursor_position_alone") |
        " \ if line("'\"") > 0 && line ("'\"") <= line("$") |
        " \ exe "normal g'\"" |
        " \ endif |
        " \ endif
        "







        www.peimankhosravi.co.uk || Subscribe to RSS Feed

        To receive emails about upcoming concerts visit this page & enter your email address in the 'follow' section.



        On 10 May 2013 09:39, huubby zhou <huubby1@...> wrote:
        I guess you add the map at the end of python.vim, is that correct?

        If so, I suggest you move your map command to before
           if exists('*<SID>Python_jump') | finish | endif

        If no, please give your python.vim.


        On Thu, May 9, 2013 at 8:35 PM, peiman khosravi <peimankhosravi@...> wrote:
        Hello, 

        I'm experiencing something odd. Is it a bug or my lack of knowledge?

        I open a new window (cmnd-n). I type ':e python.py' and paste a bit of code in there, which I have copied from another document. The syntax is highlighted and all is good. 

        I then press alt-p, which is a shortcut I have defined in my /vim/plugin/python.vim file ("map <buffer> π :w <CR>:!python % <CR>"). 

        Result: Nothing happens. 

        I save the file and try again: nothing happens.

        I reopen the file, and the shortcut is now working. Am I doing something wrong?

        Many Thanks
        Peiman   

        --
        --
        You received this message from the "vim_mac" 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_mac" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
         
         

        --
        --
        You received this message from the "vim_mac" 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_mac" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
         
         


        --
        --
        You received this message from the "vim_mac" 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_mac" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
         
         

        --
        --
        You received this message from the "vim_mac" 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_mac" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
         
         
      • peiman khosravi
        I see. That makes sense. Thanks [from the newbie!] Best, Peiman *www.peimankhosravi.co.uk* || Subscribe to RSS Feed
        Message 3 of 6 , May 11, 2013
        • 0 Attachment
          I see. That makes sense. 

          Thanks [from the newbie!]

          Best,
          Peiman






          www.peimankhosravi.co.uk || Subscribe to RSS Feed

          To receive emails about upcoming concerts visit this page & enter your email address in the 'follow' section.



          On 11 May 2013 12:21, huubby zhou <huubby1@...> wrote:
          Well, it's kind of not what I mean. I thought you said you put the 
              map <buffer> π :w <CR>:!python % <CR>
          in your python.vim that underneath system vim directory, turns out I'm
          wrong, sorry for the confusing.

          I think your problem is the '<buffer>', remove that then you should be
          fine. 
              
              map <buffer> π :w <CR>:!python % <CR>
          This map command means, you want the mapping only works in current
          buffer locally. ":h map-<buffer>" if you want further details.




          On Sat, May 11, 2013 at 6:09 PM, peiman khosravi <peimankhosravi@...> wrote:
          I think I came up with a solution. 

          Made a file called 'pythonft.vim' in ftdetect/ with this content:

          au BufNewFile,BufRead *.py set filetype=python
          au BufNewFile,BufRead *.py so ~/.vim/macros/python_macros.vim

          I then defined the shortcut in python_macros.vim:

          map <buffer> π :w <CR>:!python % <CR>

          It seems to be working now.

          Thanks
          Peiman 




          On 11 May 2013 10:39, peiman khosravi <peimankhosravi@...> wrote:
          Hello, 

          Thanks for the reply. I tried your suggestion but it doesn't seem to make a difference. I've pasted the content of my .vimrc file below.

          Thanks
          Peiman


          " Configuration file for vim
          set modelines=0         " CVE-2007-2438

          " Normally we use vim-extensions. If you want true vi-compatibility
          " remove change the following statements
          set nocompatible        " Use Vim defaults instead of 100% vi compatibility
          set backspace=2         " more powerful backspacing

          " Don't write backup file if vim is being called by "crontab -e"
          au BufWrite /private/tmp/crontab.* set nowritebackup
          " Don't write backup file if vim is being called by "chpass"
          au BufWrite /private/etc/pw.* set nowritebackup

          set ai                  " auto indenting
          set history=100         " keep 100 lines of history
          set ruler               " show the cursor position
          syntax on               " syntax highlighting
          set hlsearch            " highlight the last searched term
          filetype plugin on      " use the file type plugins
          set nofoldenable
          colorscheme murphy

          map <buffer> π :w <CR>:!python % <CR>
              if exists('*<SID>Python_jump') | finish | endif

          " When editing a file, always jump to the last cursor position
          " autocmd BufReadPost *
          " \ if ! exists("g:leave_my_cursor_position_alone") |
          " \ if line("'\"") > 0 && line ("'\"") <= line("$") |
          " \ exe "normal g'\"" |
          " \ endif |
          " \ endif
          "







          www.peimankhosravi.co.uk || Subscribe to RSS Feed

          To receive emails about upcoming concerts visit this page & enter your email address in the 'follow' section.



          On 10 May 2013 09:39, huubby zhou <huubby1@...> wrote:
          I guess you add the map at the end of python.vim, is that correct?

          If so, I suggest you move your map command to before
             if exists('*<SID>Python_jump') | finish | endif

          If no, please give your python.vim.


          On Thu, May 9, 2013 at 8:35 PM, peiman khosravi <peimankhosravi@...> wrote:
          Hello, 

          I'm experiencing something odd. Is it a bug or my lack of knowledge?

          I open a new window (cmnd-n). I type ':e python.py' and paste a bit of code in there, which I have copied from another document. The syntax is highlighted and all is good. 

          I then press alt-p, which is a shortcut I have defined in my /vim/plugin/python.vim file ("map <buffer> π :w <CR>:!python % <CR>"). 

          Result: Nothing happens. 

          I save the file and try again: nothing happens.

          I reopen the file, and the shortcut is now working. Am I doing something wrong?

          Many Thanks
          Peiman   

          --
          --
          You received this message from the "vim_mac" 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_mac" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
           
           

          --
          --
          You received this message from the "vim_mac" 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_mac" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
           
           


          --
          --
          You received this message from the "vim_mac" 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_mac" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
           
           

          --
          --
          You received this message from the "vim_mac" 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_mac" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
           
           

          --
          --
          You received this message from the "vim_mac" 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_mac" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
           
           
        Your message has been successfully submitted and would be delivered to recipients shortly.