Intermediate Vim tips
kinbiko.com
kinbiko.com
It's a really amazing piece of software. It has also recently been included in Visual Studio Code to search in files.
Or am I misunderstanding your question?
I have tons of customizations in my Vim, and have very little trouble using vi or vanilla Vim when I log into production machines. It is frustrating to not have my magic this and that, but no less frustrating than it would be going from IntelliJ on my own box to Vim on someone else’s.
I wrote about this previously in the context of Vim vs Emacs, though it's similar to customized vimrc/plugins vs vanilla vimrc:
"One can reduce part of the [editor] debate down to a single question: how fully featured do you want your text editor out of the box? If you’re a DevOps engineer who spins up new environments constantly you’ll have different ideas about the best choice compared to a full stack engineer working in a single development environment that can be painstakingly setup. For the DevOps engineer, a light text editor that is installed by default is likely ideal, while for a developer with a single computer, a full-featured IDE (auto-completion, plug-ins, custom keys) is worth the high setup cost."
Like what exactly and compared to what environment?
vim scp://some-remote-box/some/path
You can jump to a directory listing by including a trailing / :help netrwYeah, and either lose all the goods of path completion or gain atrocious lag on each tab. Because of that, I rarely use netrw.
And when I tried termux on Android, oh dear lord. The whole thing breaks because of permissions issues. Had that issue on WSL too.
Lowest-common-denominator for linux and mac, mostly just "make it work if you notice it's broken". I have one file that's bash magic, and link it to everywhere it might be needed - bashrc, bash profile, etc. It's kind of monolithic, not great but at least 100% consistent for what ends up where, and avoids sourcing external stuff or requiring N different files to work. You'll see some of your pain in the repo history, change X to Y to make it osx or *nix compatible based on whichever is my primary platform.
Same goes for vim, just absolute basics for vimrc and a few very portable plugins and niceties hardwired. No package manager, just a bare directory.
Lot of other suggestions on the same HN thread: https://news.ycombinator.com/item?id=11070797
(Disclaimer: I am the author of vimswitch)
This is what I do, too. Most of mine is portable, but I have a block in bashrc that branches on uname.
When I want the power of formatting and and all the goods, I use visual editors with no shame or remorse (VS Code is my current poison of choice).
So I also can use emacs almost anywhere. (I still advocate users and admins at least be functional in vi/vim regardless). Also don't forget GNU Nano isn't out of the game either as a small almost everywhere easy to use editor.
Reduce the friction of importing your vim config non-destructively and on demand.
Quick straw poll on this... How many people like a line length limit?
My personal preference is a fairly strict 80 (barring silly things like URLs), but I've always been met with resistance to ANY line length limit. Is it really that imposing?
some_example_code = LongTypeName(argument_one=1,
argument_two=2,
argument_three=3)
(pretend that’s 80 columns), resulting in this mess when I try to look at it in a narrower view: some_example_code = LongTypeName(argument_on
↳ e=1,
argument_tw
↳ o=2,
argument_th
↳ ree=3)
Turning off word wrap doesn’t help, because then it’s an equally painful constant two-character scroll. What does help is creating indented blocks where it feels right, and letting other lines just naturally be long. some_example_code = LongTypeName(
argument_one=1,
argument_two=2,
argument_three=3,
)
some_example_code = LongTypeName(
"just a string that happens to be long; some people introduce acceptable percentages of string literals for long lines, but it’s really not necessary. let word wrap take care of it!")
(Plus: specific column counts depend on the size of your indentation.)Over the years, I've come to believe that using a hanging indent for alignment is actually better in terms of readability as opposed to aligning at a column after the opening parenthesis, brace, or bracket. It's also easier to type as well even if the editor doesn't provide an auto-indent facility (or if it's not configured correctly for some reason) since you only have to press TAB the same number of times to correctly position each formal parameter in the function definition.
As a side benefit, it also takes care of any alignment issues regardless of whether one uses tabs or spaces.
> and letting other lines just naturally be long.
Using the language's feature for string concatenation still makes it as easy to read:
some_example_code = LongTypeName(
"just a string that happens to be long; some people introduce " +
"acceptable percentages of string literals for long lines, but it's " +
"really not necessary. let word wrap take care of it!")
Another benefit of doing this is that it makes a unified diff and side-by-side diffs easier to read. Contrast the wrapped version when I add another sentence to the end of your example: diff --git a/tmp/wrapped b/tmp/wrapped
index 972537b..27e3e31 100644
--- a/tmp/wrapped
+++ b/tmp/wrapped
@@ -1,4 +1,5 @@
some_example_code = LongTypeName(
"just a string that happens to be long; some people introduce " +
"acceptable percentages of string literals for long lines, but it's " +
- "really not necessary. let word wrap take care of it!")
+ "really not necessary. let word wrap take care of it! Though unified " +
+ "and side-by-side diffs may be more difficult to read")
versus the unwrapped one: diff --git a/tmp/unwrapped b/tmp/unwrapped
index 284ef1e..db47f46 100644
--- a/tmp/unwrapped
+++ b/tmp/unwrapped
@@ -1,2 +1,2 @@
some_example_code = LongTypeName(
- "just a string that happens to be long; some people introduce acceptable percentages of string literals for long lines, but it's really not necessary. let word wrap take care of it!")
+ "just a string that happens to be long; some people introduce acceptable percentages of string literals for long lines, but it's really not necessary. let word wrap take care of it! Though unified and side-by-side diffs may be more difficult to read")
With the wrapped version, you can more easily see what I added to the end of the line in your example. In the unwrapped example, I most likely would have to either scroll horizontally to read the entire line. If the line is soft-wrapped, then I would have to realize that the second line is part of the previous line and not a different context line (soft-wrapping is simulated by hard-wrapping right after the "for long lines," comma and the space after "difficult to " based on how blockquoted text appears a rendered comment): diff --git a/tmp/unwrapped b/tmp/unwrapped
index 284ef1e..db47f46 100644
--- a/tmp/unwrapped
+++ b/tmp/unwrapped_more
@@ -1,2 +1,2 @@
some_example_code = LongTypeName(
- "just a string that happens to be long; some people introduce acceptable percentages of string literals for long lines,
but it's really not necessary. let word wrap take care of it!")
+ "just a string that happens to be long; some people introduce acceptable percentages of string literals for long lines,
but it's really not necessary. let word wrap take care of it! Though unified and side-by-side diffs may be more difficult to
read")> As a side benefit, it also takes care of any alignment issues regardless of whether one uses tabs or spaces.
That’s exactly what I said.
> Another benefit of doing this is that it makes a unified diff and side-by-side diffs easier to read.
Until you rewrap and it adds noise to the diff. I recommend a combined word/line diff instead.
Concatenation also hides whitespace problems. Not a serious error, but a very common one.
"This ends with a period." +
"But this doesn’t start with a space."At work, I've managed to get a 99 column limit, with 79 columns for comments. But yeah, some people just don't like the limit. I like it because of monitor size/font size/distance from monitor/side-by-side editor windows. Autowrap doesn't cut it.
I'll explain why for me. On my 24" 1920x1200 monitor, I want to be able comfortably fit two editor windows side-by-side where neither window auto-wraps the code. 79 columns works well for that. This is a function of my ability to read the text, which in turn is a function of font size, monitor size and viewing distance.
(I actually have many more horizontal pixels than you too, because I have three 24" 1920x1200 monitors. My center monitor typically is where my code lives, while my other monitors have other terminals open doing other things, like searching or compiling code.)
Also, I do quite a lot of numerical code where it's more important to me to line stuff up so that physical symmetries are reflected in the code, makes coding much easier and less bug prone. So I guess that also explains my bias.
But like you say, we all like different things.
I actually also like a fairly small limit on the number of rows (around 40). If my functions and methods are too complex to understand in this much space then it's time to refactor. Of course, I usually have to work on existing code and the functions/methods are not always so compact.
Plus python seems to use super_descriptive_names_which_take_up_alot_of.space()
Some things just look better that way.
set listchars=tab:→\ ,nbsp:␣,trail:·https://www.reddit.com/r/vim/comments/6onaui/vim_getting_slo...
is at least one exploration.
if executable('rg')
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
let g:ctrlp_use_caching = 0
endifIf you don't want to be banned, you're welcome to email hn@ycombinator.com and give us reason to believe that you'll follow the rules in the future.