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

140940Re: Avoid switching files with ctrl-o

Expand Messages
  • Christian Brabandt
    Jan 23, 2014
    • 0 Attachment
      On Thu, January 23, 2014 10:26, Erik Christiansen wrote:
      > On 23.01.14 10:00, Christian Brabandt wrote:
      >> I have actually also recently just thought about adding a
      >> g<C-O>/g<C-I> command to Vim, that would jump by file steps which
      >> means there would be a built-in way to do what you want.
      >
      > I'm not sure how many keys need to be pressed simultaneously to produce
      > g<C-O>, but following a recent thread, I'm using Marcin Szamotulski's
      > function, on Alt-O & Alt-I:
      >
      > nm <A-o> :call FileJump(v:count1, 'b')<cr>
      > nm <A-i> :call FileJump(v:count1, 'f')<cr>
      >
      > " Alt-O & Alt-I between files, just as ^O & ^I retrace move history:
      > " Thanks to Marcin Szamotulski.
      >
      > fun! FileJump(count, ...)
      > let backward = (a:0 >= 1 ? a:1 : 'b')
      > let ind = (backward == 'b' ? -1 : 1)
      > for x in range(a:count)
      > let file = expand('%:p')
      > while file == expand('%:p')
      > let line = line('.')
      > if ind == 1
      > exe "normal! 1\<C-I>"
      > else
      > exe "normal! 1\<C-O>"
      > endif
      > if line == line('.') && file == expand('%:p')
      > break
      > endif
      > endwhile
      > endfor
      > endfun
      >
      > Since that's a lot shorter, I figure that your version does something
      > beyond the straightforward file hopping which meets all the needs I'm
      > aware that I have. (So what are we missing out on? :-)

      It does something slightly different. My version always jumps to the
      first jump in the current file (and won't leave the file), while
      Marcin's version always jumps at least one file backwards or forwards
      (and thus won't solve the issue, the OP noticed).

      Now that I think about it, I guess my version also does not fully
      solve the OPs original question, as he wants <C-O> to stop at
      file boundaries. Oh well, I guess, I misunderstood something.

      > I ask because to my eyes, viml has that quintessentially "perl" property
      > of being "write only". Perhaps due to decades of 'C' programming, the
      > only scripting language which I have my head around is awk.

      I think, this is just a matter of being used to.

      Best,
      Christian

      --
      --
      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+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Show all 15 messages in this topic