0

Does jedi vim support anything like intellijs https://www.jetbrains.com/help/idea/structure-tool-window-file-structure-popup.html ?

2 Answers2

4

This very simple command gives you an actionable outline of your document:

:g/def\|class/#

You can map it if you don't want to type it all the time; and make it a bit cleaner in the same move:

augroup PythonStuff
    autocmd!
    autocmd FileType python nnoremap <buffer> <F12> :<C-u>g/\<def\>\\|\<class\>/#<CR>
augroup END
romainl
  • 186,200
  • 21
  • 280
  • 313
  • I wonder, is it possible to set automatically a mark at every of these points? – A S Jul 07 '17 at 19:46
  • 1
    It should be possible to put a mark on the 26 first matches with a bit of vimscript, yes. How would you use those marks? – romainl Jul 08 '17 at 06:57
  • Well, my thought wasn't exactly about Python (where you can use `gd` and the likes) but more about other kind of structured text. And in general, how can this be achieved? Collecting these "points of interest" into a list, and then assigning marks to list elements? Or is there some other way around, what do you think? – A S Jul 08 '17 at 07:56
  • 1
    The technical part doesn't sound hard at all. It's the "business" part that needs a bit of thinking. For example, it will be impossible for anyone to remember 26 mark ↔︎ symbol mappings. An obvious workaround would be to use signs but that introduces complexity. A lightweight, on-demand, actionable TOC seems enough to me. – romainl Jul 08 '17 at 08:37
  • In my particular case it's kinda 8-10 marks at the **very** maximum :) (more like 5). Also, since I'm not a programmer, the technical part doesn't seem extremely obvious to me :). For example, how to actually collect those "points of interest"? – A S Jul 08 '17 at 08:55
  • 1
    I would `:help :redir` the output of the command I posted to a variable, `:help map()` lines to letters and `:help :mark` every line with its corresponding letter in a `:help :for` loop. – romainl Jul 08 '17 at 09:16
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/148677/discussion-between-a-s-and-romainl). – A S Jul 08 '17 at 10:34
0

Found majutsushi/tagbar which does this pretty well actually. This video explains how it works with ruby too.