Live data from Hacker News

Vim After 11 Years

statico.github.com

141–150 of 254 posts

Re: Vim After 11 Years

#142

Can vim do the following? I'm editing some project with 10000 C++ files. There is some C++ file I currently don't have open, say "palette.cpp" which is in a subdirectory "project/graphics/algorithms/color/". Now I want to open palette.cpp without ever having to type, not even with tab autocompletion, that path. IntelliJ (which I do use for C++ ;)) can do this easily: just press CTRL+R, then palette.cpp, ENTER, and th…

Yes.

Re: Vim After 11 Years

#143
post #40

Lots of people seem to declare ; or , to be useless keys and remap them. They're two of my most used movement keys in certain circumstances. I used to have , remapped to but switched back when I realised what I was missing out on. I'd advise anybody else to reconsider if they've made the same mistake I did.

I use \ for , doesn't seem to clash with anything I do on a regular basis (but I'm not a power user by any means)

Re: Vim After 11 Years

#144
post #80

My single greatest tip to make vim even more amazing is to run it in a tmux session: It makes it super easy to split panes and create new windows for related things you need to do (git stuff, compilation, running tests, running a REPL, etc.)

Personally I have a mapping x that starts a terminal emulator when running under X or drops to the shell otherwise. When I work on a project I cd into its directory. Executing commands is just a matter of hitting x, doing what's necessary, and closing the terminal.

Re: Vim After 11 Years

#145
post #108
post #88

Some small vim tweaks I've recently been using myself that I find very nice: nmap :write cabbrev w nope Re-map enter to save the file. If you try to do a :w it will yell at you until you take out the cabbrev so you can retrain your muscle memory. Took me about a day to retrain. let g:EasyMotion_leader_key = ';' nmap s ;w nmap S ;b Remap s and S to be easymotion forward and backward. I never use s, since it's largely…

Space is my leader key.

yeah

Re: Vim After 11 Years

#146
post #40

Lots of people seem to declare ; or , to be useless keys and remap them. They're two of my most used movement keys in certain circumstances. I used to have , remapped to but switched back when I realised what I was missing out on. I'd advise anybody else to reconsider if they've made the same mistake I did.

Usually I use a method that I found on some Emacs-related website. It said to use text search for navigating around the file. That's why I use / pretty often. I use f, t, and related movements as arguments to actions.

Re: Vim After 11 Years

#147
post #65

netrw comes by default. No need to install NERDTree.

Good suggestion. In the article, I failed to point out that the advantage of NERDTree is its hierarchal folder view. When a project's directory structure become gigantic it's useful to see the directory structure as you edit.

netrw does that too: hit i to cycle through all the available listing style or add this line to your ~/.vimrc if you want the "tree" style by default:

    let g:netrw_liststyle = 4

Re: Vim After 11 Years

#148
post #80

My single greatest tip to make vim even more amazing is to run it in a tmux session: It makes it super easy to split panes and create new windows for related things you need to do (git stuff, compilation, running tests, running a REPL, etc.)

This is my setup as well. I open two terminal windows: the one on the left is used for "control" stuff, and the one on the right is for code. Then in each terminal I run tmux. For a Rails project, I have separate tmux windows for models, controllers, views, stylesheets, a psql prompt, etc. I've done it long enough that I know which window has which stuff, and each vim session only has a few files open, so it's easy to `:ls` and `:e #3` around. My scripts to launch tmux look like this:

    # ~/bin/ss-ctrl
    #!/bin/sh
    
    env_name=ctrl
    long_name=skillspy
    short_name=ss
    
    cd ~/src/${long_name}/site && \
    tmux new-session -d -s ${short_name}-${env_name} && \
    tmux rename-window -t ${short_name}-${env_name}:1 git && \
    tmux new-window -t ${short_name}-${env_name}:2 -n log 'RAILS_ENV=development rails s -p 3009; bash -i' && \
    tmux new-window -t ${short_name}-${env_name}:3 -n db 'ssdb; bash -i ' && \
    tmux new-window -t ${short_name}-${env_name}:4 -n misc && \
    tmux new-window -t ${short_name}-${env_name}:5 -n redis 'cd ~/src/redis-2.6.0-rc8/src && ./redis-server && date && bash -i' && \
    tmux new-window -t ${short_name}-${env_name}:6 -n sidekiq 'RAILS_ENV=development bundle exec sidekiq | tee log/sidekiq.log; date; bash -i' && \
    tmux select-window -t ${short_name}-${env_name}:1 && \
    tmux -2 attach-session -t ${short_name}-${env_name}


    # ~/bin/ss-code
    #!/bin/sh
    
    env_name=code
    long_name=skillspy
    short_name=ss
    
    cd ~/src/${long_name}/site/app/models && \
    tmux new-session -d -s ${short_name}-${env_name} && \
    tmux rename-window -t ${short_name}-${env_name}:1 models 
    
    cd ~/src/${long_name}/site/app/controllers && \
    tmux new-window -t ${short_name}-${env_name}:2 -n controllers

    cd ~/src/${long_name}/site/app/views && \
    tmux new-window -t ${short_name}-${env_name}:3 -n views
    
    cd ~/src/${long_name}/site/app/assets/stylesheets && \
    tmux new-window -t ${short_name}-${env_name}:4 -n css
    
    cd ~/src/${long_name}/site/app/assets/javascripts && \
    tmux new-window -t ${short_name}-${env_name}:5 -n js
    
    cd ~/src/${long_name}/site/app/workers && \
    tmux new-window -t ${short_name}-${env_name}:6 -n workers
    
    tmux select-window -t ${short_name}-${env_name}:1 && \
    tmux -2 attach-session -t ${short_name}-${env_name}

Re: Vim After 11 Years

#149

Here are my 2 cents set undofile " This creates a undo file that persists your undo history when the file gets closed imap >> " Double right arrow to escape from insertion mode. This is faster and more comfortable (at least for me) than to reach for tab key for some people set clipboard=unnamed " This is bridges between your Vim yanks and your system clipboard

undofile sounds great! I didn't know about it.

Some people use jj to go to the normal mode. Personally I remapped Caps Lock to Escape in my whole system, so I can go to normal mode easily.

You can yank to the system clipboard by providing appropriate register to yank into. You do that by pressing "* before the yank command (e.g. "*yy to yank the current line).

Re: Vim After 11 Years

#150
post #126
post #123

Earlier quoted context omitted.

Fastest? Like I'd realize the speed difference between xterm, urxvt or even Gnome Terminal.

Trust me, when you have really crappy hardware (Intel Atom 1.3GHz w/ 512MB mem), you will notice the difference. Execution of commands that takes 2-3 seconds on Gnome Terminal will be nearly instant on xterm.

Is rxvt slower? Recently I switched from xterm to rxvt-unicode and it's really great!
Post reply on HN