by kbenson · 7y ago · 0 comments
Any system you connect to will have Vi, and probably Vim. This makes it an ideal tool for sysadmins that might need to connect to tens or hundreds of systems to know how to use, and to have a fairly standardized behavior. In those cases, having a customized config can actually be more of a hindrance, because switching from a highly customized local Vim instance to a stock remote Vi/Vim instance can be jarring.
For anyone who is primarily a sysadmin, I would recommend sticking with the default behavior (which is rich, and lends itself to being more and more useful and they become familiar with more an more commands), and making a minimum of local config changes and plugins to suit their needs (it's a trade odd. Just choose wisely). This makes life easier when you spend a significant portion of time on random stock Vim instances (and even if it only saved a modicum of time, it saves a lot of aggravation as you don't feel like you're working with missing limbs).
Then again, I've always been one to do develop scripts remotely to help with tasks (all the easier to test int he correct environment), so other people's experiences may differ. I'm primarily doing software engineering now, so I load main vim instance with a fair amount of specialization (but probably less than most).
Perhaps it's just that the people who diligently curate their .vimrcs are more prone to talk about it than people who use stock or minimally configured vim. I can tell you my .vimrc right now without looking at it.
se sm
se hls
se number
se ts=4
se sw=4
se expandtab
It's not very exciting. Nobody ever writes a blogpost on the virtues of a vimrc that looks like this one.The rest of the stuff I have boils down to history size, a fixup for backspace in insert, default paste mode and quick key to toggle it, how far from margins to start scrolling, and turning off swap files so editing very large files is easier. Oh, and the Pathogen init stuff, for which I have usually have no modules installed (but I test out stuff occasionally), but there it sits.
Now that I've gotten out of it, I see that there are only a few small customizations that I really enjoy, but none that I need. And I can now use VIM on any machine.
"instead of se number
se nu
I’ve found this to be true. I’m getting a little annoyed with the narrative that it’s best not to customize Vim much because you won’t have those customizations on the generic boxes you’re working on.
You don’t forget vanilla Vim; to me, that’s kind of the point. You’d be surprised how much of generic Vim becomes muscle memory and you do things you haven’t thought about in a while. When you become a proficient Vim user, it kinda just happens.
However, I hardly ever read anything advocating for a different approach: using Vim’s netrw support for ssh, scp and several other protocols from your main machine, allowing you to use your fully configured Vim to edit files on those machines you’re performing sysadmin tasks on.
Once you’ve configured things, you can just
vim scp://[user@]machine/path
Obviously this won’t always be an option, but when you can, why not? Netrw is a plugin that comes with Vim, so even Vim minimalists can use it even if they have zero 3rd-party plugins installed.It’s even in Vim’s docs:
http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw-ss...
http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw-tr...
It doesn't really matter much whether you use tabs or spaces, or how many spaces a tab key (or tab character) represents, but having to swap between them multiple times a day gets... tiresome. There's a fluidity that comes with your tool behaving how you expect, and a time of acclimation when it changes. Whether the benefits of either keeping your config close to stock to reduce this acclimation period or highly customizing your personal Vim to be as efficient as possible is the better solution probably depends on the individual and the relative amount of time spent in each environment.
I'm not really urging one approach over the other, but rather noting that one should be cognizant of this, as it may allow for better decisions at different times. I, for one, found certain Vim customizations to be not worth the effort at one point when I was doing a lot of remote Sysadmin work, but worth investigating more when my time in Vim shifted more towards being used in one main instance.
As a simple example, if you spend 80%-90% of your time on remote servers, how useful is it to install Nerdtree on your main instance and spend the time configuring and learning how to use it well? Are the keys to Vim split windows and resizing better, or perhaps figuring out how to do that in screen/tmux is more effective a that time (can that be assumed to be on the servers?).
If nothing else, I think it helps explain why some people are so enamored of some Vim plugins, while others try them and consider them "meh".
1 admin with 1-10 servers is not much of a problem. As the number of admins and/or servers scales up, it starts becoming much more of a problem. I've worked in environments with 1-2 admins and <10 servers, and in environments with 20+ admins and hundreds of servers. In the latter environment, if you left an altered Vim config on a shared admin account, that's likely something you would be called out for, and rightly so. If anything doesn't look right when you're called onto a server at 3 AM to fix some random malfunction that's hard to diagnose, you start grasping at it as something that needs to be ruled out as part of the problem. Irate early morning emails from annoyed sysadmins over inconsistent server state are common.
Was never able to adopt it as my main editor. The bifurcated input/command modes always trip me up.
Not sure if it's ubuntu or vim, but it comes with some really annoying changes that haevn't been this jarring since moving from solaris-vi to the vim bundled with ubuntu (vim-nox) over a decade ago.
The two most annoying things I really noticed and massively reduced my efficency
1) Get about 6 lines from the bottom and the cursor no longer moves.
2) Search moves the window as you're typing
It really pissed me off2) That’s incsearch, `set noincsearch` to turn it off.
My own desktop's vimrc has a few useful shortcuts (F5 for example to "compile" a graphviz file to dot -T x11 -- my VB3 roots showing), but the majority of vim use across the estate has never needed it before.
Fortunately I do have a facility to distribute .vimrc to undo these disastrous changes, but changing the default behaviour was rather annoying for an editor that is so ubiquitous.
One problem I've found with vim is some weird character buffer thing happens where my text stops displaying or something. I've never investigated it but its probably SSH itself.
"don't customize your VIM, what if you have to use vi/vim on a server?" trope.
I submit that if you're having to log into individual servers enough to make those kinds of changes, you're already engaged in a systems management anti-pattern.
Code up some CM/automation to handle that.
You can probably write that code from your workstation, with your more customized Vim. :-)
If I had to distill my point down to a sentence, it would be "be cognizant of your tools and their usage paradigms, and whether large customizations to one paradigm and how it might affect the overall usability, or your perception thereof, of the others."
Yes, it's wordy, but that's simply because not everything is easily reduced to a pithy one-liner, at least not without a large loss of context.
You wrote:
> For anyone who is primarily a sysadmin, I would recommend sticking with the default behavior
Am I reading that wrong?
"Don't customize the default behavior if you're a sysadmin"
Do you not agree with what you wrote?
I'm simply arguing that, as a sysadmin today, you're far better served eliminating the need for N node access to make changes, and using your customized local config to push changes to a repository that is applied by a CM-esque system.
For anyone who is primarily a sysadmin, I would recommend sticking with the default behavior (which is rich, and lends itself to being more and more useful and they become familiar with more an more commands), and making a minimum of local config changes and plugins to suit their needs (it's a trade odd. Just choose wisely).
The key (corrected) part you're missing is "it's a trade off. Just choose wisely." I go into more detail on that in subsequent comments to other replies.
> I'm simply arguing that, as a sysadmin today, you're far better served eliminating the need for N node access to make changes, and using your customized local config to push changes to a repository that is applied by a CM-esque system.
That good for many things, but not really an adequate solution for diagnosing a problem under stress.
>Any system you connect to will have Vi, and probably Vim. This makes it an ideal tool for sysadmins that might need to connect to tens or hundreds of systems to know how to use, and to have a fairly standardized behavior. In those cases, having a customized config can actually be more of a hindrance, because switching from a highly customized local Vim instance to a stock remote Vi/Vim instance can be jarring.
That's a great point. I had mentioned something to the same effect, briefly, in the blurb for my vi quickstart tutorial, here:
https://gumroad.com/l/vi_quick
I first wrote that tutorial at the request of a couple of Windows system admin friends of mine (at a company where I worked earlier), who were tasked with managing a few Unix boxes, without knowing Unix. They used the tutorial and later told me that it helped them to quickly start using vi to do their work on those boxes, including editing config files, simple shell scripts, etc.
Edit: Since vi is mostly a subset of vim, the tutorial works for vim too.