You are not logged in.
I've been using Vim for about a year now, but I know that I'm not using it to its full potential. I've finally gotten used to the "HKJL" movement within files, and I have my .vimrc set to handle autoindents and tabs how I want, but that's about it.
So - I'm looking for a few simple things that I can do to make my editor work better for me. I've been considering swapping my Esc and CapsLock for a while now, and I think that would be a good start, but I have no idea how to do it.
I'm serious about learning to use Vim (and Linux) effectively in my work, which is web development (usually Python/Django, though I have to drop back to PHP to work on legacy stuff from time to time). I've settled on ScrotWM for right now, but love my tiling WMs. I just feel like a gimp because I can't do magic with my editor, and I don't know anyone else in my area that uses Linux seriously.
Last edited by SimonPhotography (2009-10-29 13:25:29)
Offline
Just keep doing :help within Vim.
And read this link: http://rayninfo.co.uk/vimtips.html
Offline
I have mapped Esc to CapsLock. This is my .Xmodmap file:
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
The only problem is that this works in X but not in virtual consoles. In virtual consoles I still have to use Esc key. Not so big problem as I use X all the time.
Offline
I have mapped Esc to CapsLock. This is my .Xmodmap file:
remove Lock = Caps_Lock keysym Caps_Lock = Escape
The only problem is that this works in X but not in virtual consoles. In virtual consoles I still have to use Esc key. Not so big problem as I use X all the time.
Thanks! I'll take care of this as soon as I open my laptop next I hate using Windows at work, but I have no choice
Offline
I suggest watching Bram Moolenaar's (the developer of Vim) presentation on effective text editing.
Basically it boils down to:
1. Know when you're being inefficient
2. Find a more efficient way to do that
3. Make it a habit
Last edited by artoj (2009-10-29 14:42:31)
Offline
Master the find and replace:
:%s/<find>/<replace>/g
It's just like sed.
(I am so going to watch that text editing video.)
Last edited by timetrap (2009-10-29 14:44:44)
Offline
I have mapped Esc to CapsLock. The only problem is that this works in X but not in virtual consoles. In virtual consoles I still have to use Esc key. Not so big problem as I use X all the time.
/etc/rc.conf:
KEYMAP="custom"
/usr/share/kbd/keymaps/i386/qwerty/custom.map.gz
... standard keycodes snipped ...
keycode 58 = Escape
Though I have it mapped to "Control", to make screen easier.
Offline
Or to remove complications you can just do:
Ctrl-[
To get Escape.
Offline
The only problem is that this works in X but not in virtual consoles. In virtual consoles I still have to use Esc key. Not so big problem as I use X all the time.
You can put
echo keycode 58 = Escape | loadkeys -
into /etc/rc.local.
Offline
Or do it the fun way!:
for i in $(find /usr/share/kbd/keymaps/ -name $(sed -n "/^KEYMAP/{s/.*\"\\(.*\\)\".*/\\1.map.gz/;p}" /etc/rc.conf)); do gunzip -c <$i| sed "s/Escape/Caps_Lock/;t;s/Caps_Lock/Escape/"|gzip - > $(echo $i|sed "s/.map.gz$/-capsesc.map.gz/") ; done
(fetches your rc.conf set keymap switches caps lock and escape and saves it in the same place as the other, but instead of with x.map.gz it sets x-capsesc.map.gz as name...)
Edit in case it's not obvious: You'll need write permissions whereever it wants to save the file, yes it normally means root, no I will not take any responsibility, but of course I've run it on my own computer without detecting any probl
20:59 tlvb [n=leo@c-83-256-146-293.cust.bredband2.com] has quit [Read error: 110 (Connection timed out)]
Last edited by tlvb (2009-10-29 20:03:54)
I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.
Offline
I personally map Caps Lock to Backspace which I think you would like more than if you mapped it to Escape. One thing you will love is this though:
map ; :
No more shift+; to enter commands!
Last edited by linkmaster03 (2009-10-29 20:32:19)
Offline
The greatest thing ever. Maps : to ; in normal mode:
map ; :
Offline
I've finally gotten used to the "HKJL" movement within files
Needs moar NetHack!
Apply settings only for gVim
"GUI Options
if has("gui_running")
set gfn=Monospace\ 12
set guioptions-=rTm
colorscheme zenburn
set showtabline=2
endif
This way I can use a colorscheme that looks fine under the terminal, and one that looks fine under X, depending on my mood.
Some nice text "wrapping"
set wrap nowrap
set sidescroll=3
set listchars+=precedes:<,extends:>
Last edited by Lich (2009-10-29 21:30:44)
Archlinux | ratpoison + evilwm | urxvtc | tmux
Offline
Registers are nice:
CTR+R % will insert file name in insert mode
:let @/=""
use g* then
:grep <CTRL-R /> * to look for the word under the cursor, then grep it it all files
:copen to see the results
(using * on word foo will put \<foo\> on the search register, which is less useful)
quick-fix mode is nice:
:copen, :cn, and so on
nice plugins:
A.vim , supertab, ...
CTRL-Y in insert mode insert the same character that are on the above line.
CTR-V in normal mode to edit rectangle of text:
foo(bar, baz);
foo(42. 21);
press CTR-V then j then e then c then fun then escape (twice), and you'll have:
fun(bar, baz);
fun(42. 21);
CTRL-A / CTRL-Z in insert mode to increment / decrement the number under the cursor.
Very useful combined with macros.
Offline
You might find some at http://dailyvim.blogspot.com. Nice blog imo.
Offline
The greatest thing ever. Maps : to ; in normal mode:
map ; :
Dear FSM. How did I not think of this before?
Offline
press qq before doing anything you're going to repeat
alt+key in insert mode means key in normal mode, faster than pressing esc
Offline
ArchArael wrote:I have mapped Esc to CapsLock. The only problem is that this works in X but not in virtual consoles. In virtual consoles I still have to use Esc key. Not so big problem as I use X all the time.
/etc/rc.conf:
KEYMAP="custom"/usr/share/kbd/keymaps/i386/qwerty/custom.map.gz
... standard keycodes snipped ...
keycode 58 = EscapeThough I have it mapped to "Control", to make screen easier.
ArchArael wrote:The only problem is that this works in X but not in virtual consoles. In virtual consoles I still have to use Esc key. Not so big problem as I use X all the time.
You can put
echo keycode 58 = Escape | loadkeys -
into /etc/rc.local.
Thank you for your tips guys.
Offline
:h object-select
Strangely, a lot of people doesn't know about these.
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
skottish wrote:The greatest thing ever. Maps : to ; in normal mode:
map ; :
Dear FSM. How did I not think of this before?
Repeating what was in the post before me doesn't make me look smart? Damn!
*** Beaten by nine seconds ***
Offline
The greatest thing ever. Maps : to ; in normal mode:
map ; :
So what do you use for ; ? The ";" key is very useful for efficient editing, it repeats the last f or t command.
If you have:
[f]unction(arg1, arg2, arg3)
I'm sure you all know doing f, will give you:
function(arg1[,] arg2, arg3)
But instead of pressing f, again, you can use ; to repeat your command and get.
function(arg1, arg2[,] arg3)
Very useful (though in this case you could use W or E as well.
Offline
I second MrElendig on :help text-objects/object-select, but I'd like to add g;/g, and friends. Very useful to navigate somewhere and hit g; to go back where I was without having to set and remember marks all the time.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline
Reindent a file (in default mode): gg=G
Select all text: ggVG
Also, learn how to use the aw/iw (a word/inner word) et al. modifiers. This way, you could have the cursor anywhere in the word and can do commands like "daw" to delete the whole word, or "caw" to change it, etc.
About the "qq" macro thing: that defines a macro (the first q) called "q" (the second q). You type in all the stuff you would normally do, type "q" again to end it. Then you can use the "@q" command to repeat the "q" macro (or whatever letter you save it in).
Also, one of my favourite visual selectors in vim is the Ctrl+V visual mode. You can select a two-dimensional block of text (similar to the mark text thing in MS cmd.exe) and perform commands on it (doesn't seem to work with :s//, however).
Last edited by mjunx (2009-11-12 07:35:50)
Offline
(doesn't seem to work with :s//, however).
This script adds that functionality.
http://www.vim.org/scripts/script.php?script_id=1195
The syntax is:
B s/ooga/booga/g
Offline
skottish wrote:The greatest thing ever. Maps : to ; in normal mode:
map ; :
So what do you use for ; ? The ";" key is very useful for efficient editing, it repeats the last f or t command.
Oh, that's very useful as well... dammit. Guess I'll have to press shift every now and again for :, then.
Last edited by Pox (2009-11-13 06:29:00)
Offline