6 ms·
Intermediate Vim tips
- i_feel_great 9y agoWhere have you been all my life, "set cursorcolumn"?
- mythrwy 9y agoLOL that was my exact thought. Added to .vimrc. But will never get back all the time lost trying to make sure I was at proper indent level.
- brian-armstrong 9y agoI highly highly recommend always using a linter/formatter that just fixes this for you
- mythrwy 9y agoPython. Indention matters. Unless there is a linter that can tell intent (and maybe there is on that offers an option?) indention can be the difference between once and forever.
- seuss1969 9y agoIf you like the idea of cursorline, take a look at this snippet I found while searching dot files: https://github.com/darnir/dotfiles/blob/eb26d9a0f3df1650df0ef17cb67dba3de57ae61d/Packages/NeoVim/nvim/init.vim#L414 https://github.com/darnir/dotfiles/blob/eb26d9a0f3df1650df0e...
- unknown_apostle 9y agoIs it me, or does cursorcolumn really give Vim a bit of a sluggish feel?
- mcmatterson 9y agoIt's not just you. I noticed it a few months ago and ended up disabling cursorline entirely. It seems to be caused by an intersection of cursorline and specific syntax highlighting rules (it happens for me in Elixir, but not in Ruby, for example). Honestly, while line highlighting is nice, I can't be bothered figuring out the way through it. https://www.reddit.com/r/vim/comments/6onaui/vim_getting_slow_with_cursorline_and_cursorcolumn/ https://www.reddit.com/r/vim/comments/6onaui/vim_getting_slo... is at least one exploration.
- n1cked 9y agoI've done a similar thing with my whitespace, but prefer characters that I'm less likely to have typed myself (like a small arrow for tab). set listchars=tab:→\ ,nbsp:␣,trail:·
- hzhou321 9y agoI am so glad that I can live without these tips. As I grow older, every year I feel the need to cut down on my essentials. My .vimrc gets shorter every year. Earlier, I was so annoyed by the default parentheses highlighting yet so dislike the solutions of adding more lines to my .vimrc, I was forced to do some research and found out that all I need to do is to delete the plugin from /usr/share/.... I deleted the entire plugins folder there. I felt like Picaaso.
- deleted 9y ago[deleted]
- nulagrithom 9y ago> I don't like excessively long lines of code (120+ in most languages) 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?
- burntsushi 9y agoI'm also at a fairly strict 80 (errm, 79 inclusive). 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.
- semi-extrinsic 9y agoI don't get the 80 char limit at all. But then my display is 43" at 3810 pixels horizontally, so at my normal font size I would be able to fit, what, 7 or 8 windows side by side at 80 columns wide?
- burntsushi 9y agoWhat don't you get about it? I can understand you having a different preference. That's normal, we all like different things. But not getting it at all? That's just weird. 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.)
- semi-extrinsic 9y agoI suppose I phrased it badly - I meant I don't get why anyone would have a limit as low as 80 unless they're coding on an Apple II or a 10" netbook. But you fill your 24" 1920x1080 with 160 characters and change? That's like font size 18, just sounds huge to me. But hey, it's your display. 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.
- baby_wipe 9y agoI’m probably the minority here but I don’t like to customize my Vim too much. 1 - it takes time. 2 - half the reason I like Vim is because I can use it anywhere. If I’m so used to a highly customized setup, then I am going to feel out of place when I log on somewhere else.
- crehn 9y agoSame. I spend most of my time in a terminal and SSH into various boxes daily. I do customize my standard Unix toolset, but avoid plugins and non-standard configs that increase cognitive burden. It's very liberating to feel comfortable with shitty defaults. If you feel at home with the defaults, you feel at home anywhere.
- oftenwrong 9y agoYou can remotely edit on any system accessible over ssh thanks to netrw: vim scp://some-remote-box/some/path You can jump to a directory listing by including a trailing / :help netrw
- icen 9y agoEmacs has Tramp, and you can do the same thing!
- yjftsjthsd-h 9y agoIs there a way to combine this with sudo, to edit root's files remotely? Apparently tramp is supposed to support this, but I prefer vim.
- dozzie 9y ago> You can remotely edit on any system accessible over ssh thanks to netrw: Yeah, and either lose all the goods of path completion or gain atrocious lag on each tab. Because of that, I rarely use netrw.
- joeskyyy 9y agoRight there with you. While the power of vim is to be able to customize it, I hate getting used to something and then not being able to use it everywhere. I've managed to get by with no extra .vimrc things whatsoever for quite some time :D Does it take me longer to do some things compared to using what's in this article? Yup. Does it prevent me from doing good, and still relatively quick, work? Nope. 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).
- Jeaye 9y agoFor anyone wanting to peruse another large vim setup (mostly C++ and Clojure): https://github.com/jeaye/vimrc https://github.com/jeaye/vimrc
- keithnz 9y agoI use vim bindings in visual studio and do a lot of custom binding to resharper functionality. It's quite magic, the only thing I really miss from Vim is easy motion and the vim emulation is not complete so for some editing tasks I have to open a file in Vim.
- lillesvin 9y agoWhenever a Vim post mentions grep, ack or ag — especially in conjunction with fzf/fzy — I'll make sure to mention the even faster rg (ripgrep): https://github.com/BurntSushi/ripgrep https://github.com/BurntSushi/ripgrep BurntSushi's write-up about the internal workings of ripgrep is also super interesting: http://blog.burntsushi.net/ripgrep/ http://blog.burntsushi.net/ripgrep/) It's a really amazing piece of software. It has also recently been included in Visual Studio Code to search in files.
- huntie 9y agoI use ripgrep and it's pretty great, but I don't know why Visual Studio Code would be using it. Why not just use Rust's Regex library instead?
- dfee 9y agoIs it? Funny because I have tmux open in the side pane, and execute my searches that way.
- lillesvin 9y agoYup: https://users.rust-lang.org/t/ripgrep-is-now-the-standard-text-search-provider-in-vs-code/10285 https://users.rust-lang.org/t/ripgrep-is-now-the-standard-te...
- lillesvin 9y agoI'm just guessing here, but ripgrep is an executable that they can bundle and write a simple wrapper around. VSCode isn't written in Rust so they'd have to write their own "grep" in Rust which most likely wouldn't be anywhere near as good as ripgrep. Or am I misunderstanding your question?
- burntsushi 9y agoWell, ripgrep uses Rust's regex library. If VS code used the regex library directly, then they would basically wind up re-creating ripgrep (or something very similar) itself.
- ekianjo 9y agoI dont use fzf but CtrlP for vim is also very good at fuzzy search.
- jackyinger 9y agoCtrlP enables my habit of having gazillions of buffers open when working on large projects. It’s great with splits.
- hitripley 9y agoCtrlP is much slower when indexing large directories.
- spapas82 9y agoCtrlP works great with Windows VIM!
- oddlydrawn 9y agoCtrlP is nice but pretty slow. You can try ripgrep with CtrlP using: if executable('rg') let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""' let g:ctrlp_use_caching = 0 endif
- minusf 9y agoi find unite.vim very useful https://github.com/Shougo/unite.vim https://github.com/Shougo/unite.vim
- geezk7 9y agoDo you even emacs bro?
- dang 9y agoWe've banned this account for repeatedly posting unsubstantive and uncivil comments to HN. If 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.
- unknown_apostle 9y agoHaving a free day, it's cold and rainy, but this actually made me come out of bed to crank up vim :-)