3 ms·
I use vim as my IDE daily, and swear by it. I was just thinking of things that I still 'shell out' for because it feels more convenient and wanted to get other
by throwaway238947 5y ago
I use vim as my IDE daily, and swear by it. I was just thinking of things that I still 'shell out' for because it feels more convenient and wanted to get other people's opinion on how they solve it.
1) Open a file (in a split) in the same git repo that shows up under 'git status'. I'm way too comfortable hitting ctrl-z, git s, grab mouse, copy, fg, :sp ctrl<v>. Is there a simple pattern/plugin to just list modified files and open one in a split?
2) Open a file in another repo. So I'm in src/foo, and I need to open a file (in a split) in src/bar. I often use NerdTree for this but it feels slow and cumbersome, but maybe I'm using nerdtree wrong? Something like being able to just type <leader><key> <start typing a path and get fzf-style results> or something like that.
3) Find where a function/method is defined in the current git repo. Right now my pattern is I have Ack search (but using fzf) bound to backslash, so I type like \'def funcname' but this feels so cumbersome. Is there a faster way to just say "open the file where the function name my cursor is in is defined"?
For reference, in the shell I tend to rely heavily on fzf and fzf-using functions (e.g. 'vis' will let me select from changed files via fzf and open it in vim, 'vif' will let me select from any filename under the current dir in vim) and I guess I'm mostly looking for bringing that power and flexibility into vim without shelling out or lots of arrow-arrow-return-arrow-arrow-return in nerdtree.
- sodapopcan 5y ago1) I just use fugitive[0] for that. `git status` in vim is now just the `:G`, command, though I map it to `gs` so it's even quicker. 2) I can't really help you there, at least not in vanilla vim. I make heavy use of tmux and never work on my more than one repo in the same vim instance, nor is my vim's current working directory every anything other than the root of the repo I'm in. So if I do need to open a file in another repo and want to see two repos side-by-side (which is rare but it happens), I make a tmux split. 3) gutentags [1] can help with this. Though nothing is better than using a language server for your given language. That said, I still just have gutentags and mostly just grep/search for `def func` like you currently do. [0] https://github.com/tpope/vim-fugitive https://github.com/tpope/vim-fugitive [1] https://github.com/ludovicchabant/vim-gutentags https://github.com/ludovicchabant/vim-gutentags
- blobdon 5y agoFor (2), I have the following in my .vimrc and it does close to what you've described: nnoremap <C-p> :FZF ~/src<CR> I feel like there you could make it open the result in a split either by modifying this mapping command, or by hitting something other than enter once you have your target selected in the fzf window. I just open the split first, then C-p in the split.
- makeva 5y agoFor 2) I Haven't tested it yet, but the GitHub post about the new git version was speaking about a git jump plugin that does that it seems
- faisalhackshah 5y ago1. Fugitive.vim 2. Fzf.vim . If you launch vim from a path includes both repos, it will just work. If not, you can provide a starting path argument to the fzf file picker. 3. ctags (universal-ctags) + native vim tag jump functionality. Pair with gutentags plug-in to auto generate ctags when files change and the such.
- yasenn 5y ago1) vim-fugitive: > Called with no arguments, `:Git` opens a summary window with dirty files and unpushed and unpulled commits. Press `g?` to bring up a list of maps for numerous operations including diffing, staging, committing, rebasing, and stashing. (This is the successor to the old `:Gstatus`.) [1] To open file in split: <C-w>f 2) fugitive works with it too. See this thread [2] 3) I use fzf [3] too. My pattern is a bit shorter: '\r' (mnemonic from '' for search the word under cursor). With the mapping and command: ``` nnoremap <silent> <Leader>r* :Rgw <C-R><C-W><CR> "" <C-R><C-W> - to paste word under cursor in command prompt command! -bang -nargs=* Rgw \ call fzf#vim#grep( \ 'rg -w --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1, \ <bang>0 ? fzf#vim#with_preview('up:60%') \ : fzf#vim#with_preview('right:50%:hidden', '?'), \ <bang>0) ``` [1]: https://github.com/tpope/vim-fugitive/blob/master/README.markdown https://github.com/tpope/vim-fugitive/blob/master/README.mar... [2]: https://vi.stackexchange.com/a/20671 https://vi.stackexchange.com/a/20671 [3]: https://vimawesome.com/plugin/fzf-vim https://vimawesome.com/plugin/fzf-vim
- YuukiRey 5y agoFor 2) you might want to look into :lcd. This changes the directory of the current window (there are other commands to cd for different contexts). So what I do is ctrl-w v to split, followed by :lcd /some/path and then, in that window, I can use my fuzzy finder (or :grep). It's still quite a few commands but the advantage is that you get a buffer where all your commands should operate on $other_repo.