3 ms·
This is unfortunately not uncommon. I feel like most of my coworkers at most companies Ive worked for don't use vim. One killer app of vim for me is macros. You
by archarios 6y ago
This is unfortunately not uncommon. I feel like most of my coworkers at most companies Ive worked for don't use vim. One killer app of vim for me is macros. You can record a string of commands and map doing that to a letter. This makes certain mundane changes you have to do sometimes in software a breeze. For example, I had some code where someone was using string literals everywhere when they should have defined an enum. The convention we use for this kind of thing is to use UPPER_SNAKE_CASE and the strings were in camelCase. I was able to define two macros that let me improve this code in a few seconds. If I wasn't using vim I'd probably just leave that code as it was because it would have been so much effort.
- j-james 6y ago> If I wasn't using vim I'd probably just leave that code as it was because it would have been so much effort. Most modern editors, Visual Studio Code included, have powerful refactoring abilities. Not only that, but they're usable without needing to be an editor expert - just right-clicking and selecting "Change all occurrences" (or pressing F2) does the trick.
- read_if_gay_ 6y agoThis is reasonably fast, but not nearly as fast as if can be on Vim. IDK how GP did it, but one quick way might be searching for strings and hitting . whenever the macro needs to be applied. So you would end up doing something like n n n . n n . n n and so on, where each n means “go to next string” and each dot corresponds to finding and renaming something manually in other editors. You can go through dozens of occurrences in seconds, orders of magnitude faster than other editors.
- allannienhuis 6y agoThe vscode rename is much simpler/faster than that - cursor over the symbol/variable, press F2, type in the new name, press enter. Renames all references across all files in your project. edit: no shade on VIM and VIM macros; they're great. I'm a very experienced vim power user, but have switched to vscode with vim keybindings, and I'm very very happy with the switch.
- xfer 6y agoYou're conveniently forgetting that this works for only supported languages. These things are also possible in vim with additional plugin for your language.
- read_if_gay_ 6y agoThis is true for renaming a variable but GP mentioned converting string literals to enums. For tasks like that, I think Vim is pretty much the fastest. Also, Vim can also rename variables with coc (https://github.com/neoclide/coc.nvim https://github.com/neoclide/coc.nvim)
- archarios 6y agoThe change I was just describing is much more complicated than a simple rename.
- saagarjha 6y ago> One killer app of vim for me is macros. You can record a string of commands and map doing that to a letter. Nano lets you do that too.