From e6e08cb80dc77348a6fae63da140ee29232bfdc1 Mon Sep 17 00:00:00 2001 From: zevav Date: Tue, 30 Jul 2019 23:05:58 +0200 Subject: [PATCH] alignment, more content on vim post --- blog/vim_and_ctags.html | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/blog/vim_and_ctags.html b/blog/vim_and_ctags.html index 7b7c8fd..127f092 100644 --- a/blog/vim_and_ctags.html +++ b/blog/vim_and_ctags.html @@ -110,7 +110,7 @@ << back to blog index -
How I Got "Go To Definition" Working in Vim in 2019
+
How I Got "Go To Definition" Working in Vim in 2019

@@ -122,7 +122,6 @@ set tags=tags autocmd BufWritePost *.py silent! !ctags -R --python-kinds=-i --languages=python 2> /dev/null & $ brew install ctags -

@@ -135,7 +134,7 @@ $ brew install ctags compared to vim.

-
What I Miss From IDEs
+
What I Miss From IDEs

Because I'm not yet a sed/grep expert in the context of search and replace, I still miss the @@ -148,7 +147,7 @@ Because I'm not yet a sed/grep expert in the context o ctrl-] as it is by default in vim.

-
Getting It To Work + Timesucks to Avoid
+
Getting It To Work + Timesucks to Avoid

As with most of my efforts to make vim more ergonomic/IDE-like, getting "go to definition" working took @@ -156,9 +155,9 @@ Because I'm not yet a sed/grep expert in the context o

For the uninitiated, while vim comes with ctrl-] out of the box, it - doesn't actually know where something is defined unless there's at least one `tags` file and you've told vim - where to find it/them. You can run `ctags` manually, but this can get tiresome if you want vim to - always have an updated index of where all the definitions are in your project: functions, modules, + doesn't actually know where something is defined unless there's at least one tags file and you've told vim + where to find it/them. You can run ctags manually, but this can get tiresome if you want vim to + always have an updated idea of where all the definitions are in your project: functions, modules, constants, classes, types, etc.

@@ -172,10 +171,6 @@ but for whatever reason the tags file never refreshed on commit. Avoid this rabb

What ended up working to refresh the tags file *on every save* was a modified version of something I found in the comments of a StackOverflow answer. - I was only interested to start out with in tagging my Python projects, so I - modified it accordingly. -

-

However, without python-kinds=-i, "go to definition" didn't work as expected on MacOS (it was fine on an Ubuntu droplet). Inspecting my tags file, @@ -183,23 +178,31 @@ but for whatever reason the tags file never refreshed on commit. Avoid this rabb module, where the import was, not to the definition of the entity.

-
Final Product + User Experience
+
Final Product + Developer Experience

- What's nice about this usage of ctags is 1) it runs in the background and never + I can now very quickly navigate to where whatever's under my cursor was defined + with a single keystroke. What's nice about this usage of ctags is 1) it runs in the background and never interrupts you, 2) it's fast, and 3) it runs every time you save. - I haven't tried this at all with JS yet, and Mr. Pope alludes to that ctags might not be as - helpful there, but it is lightning fast and accurate for jumping around in large Python-based + I haven't tried this at all with JS yet (will be trying this), and Mr. Pope alludes to that ctags might not be as + helpful there, but it is lightning fast and accurate for jumping around in large Python-based projects.

-
Bonus: gf
+
Bonus: gf

gf bridges a significant gap that ctags don't cover: It stands for "go to file". Type gf in normal mode when your cursor's over a filename, and it opens it!

+
Next Thing to Try: Tagging dependencies and the Python standard lib
+

+ As mentioned above, you can tell vim about multiple tags files in multiple paths. It + doesn't come up as often that I want to "go to definition" of library code, but I can see how it + might come in handy. +