Navigate through your search history (/) or command history (:) without leaving your home row?
q:
q/
Think "query search" and "query command"
Practical vim tips and trick for all level
bindkey -M emacs |grep edit-command
"^X^E" edit-command-line
ctrl x ctrl e pour editer la commande actuelle via vim
:echo @% def/my.txt directory/name of file (relative to the current working directory of /abc)
:echo expand('%:t') my.txt name of file ('tail')
:echo expand('%:p') /abc/def/my.txt full path
:echo expand('%:p:h') /abc/def directory containing file ('head')
:echo expand('%:p:h:t') def First get the full path with :p (/abc/def/my.txt), then get the head of that with :h (/abc/def), then get the tail of that with :t (def)
:echo expand('%:r') def/my name of file less one extension ('root')
:echo expand('%:e') txt name of file's extension ('extension')
le plugin Ack permet de chercher dans le repertoire courant de vim (celui qu'on voit avec :pwd)
Pour chercher seulement dans un seul repertoire, il faut changer ce repertoire courant. Quelques commandes pratiques :
:Gcd (fournit par fugitive vim) permet de remonter à la racine du repot git
Dans nerdtree, si on se place sur un repertoire et qu'on fait 'cd', le repertoire courant de vim est changé
Une fois dans le bon repertoire, on peut chercher avec :Ack! pattern
Appending to a named register
Using an uppercase letter tells Vim to append text to the specified register (rather than overwriting the existing contents). For example, "Ayy copies the current line, and appends it to register ‘a’.
<3
You can do " to paste from the default register or a to paste from register a.
Additionally:
Ctrl-y Moves screen up one line
Ctrl-e Moves screen down one line
Ctrl-u Moves cursor & screen up ½ page
Ctrl-d Moves cursor & screen down ½ page
Ctrl-b Moves screen up one page, cursor to last line
Ctrl-f Moves screen down one page, cursor to first line
Ctrl-y and Ctrl-e only change the cursor position if it would be moved off screen.
I try to use vim without any plugins as I don't want to rely on them when I work on another system. Coming upon this same issue now, I can propose some 'better ways' (alternative ways) as requested by the OP:
c-w-| to have window take over (if using vsplits). c-w-= to restore. c-w-_ for horizontal splits
close the other window(s), thereby making current one fullscreen. Split and re-open from buffer to restore
Comment j'ai fait pour me passer de nerdtree?
current line in top of screen : z
go to next blank line (paragraph) : }
:Glog
:clist
:cprev
:cnext
:cfirst
:clast
I've edited my .vimrc to add fugitive plugin and commited it by using fugitive
Comment perdre 30 min
:set backupcopy=yes
When you want to modify a file, you have two options, each with its benefits and drawbacks.
You can overwrite the file in place. This does not use any extra space, and conserves the hard links, permissions and any other attribute beyond the content of the existing file. The major drawback of doing this is that if anything happens while the file is being written (the application crashes, or the power goes out), you end up with a partially written file.
You can write the new version of the file to a new file with a different name, then move it into place. This uses more space and breaks hard links, and if you have write permissions on a file but not on the directory it contains, you can't do it at all. On the flip side, the old version of the file is atomically replaced by the new version, so at every point in time the file name points to a valid, complete version of the file.
http://vimdoc.sourceforge.net/htmldoc/options.html#%27backup%27
je découvre ce plugin vim qui a l'air juste magique pour interagir avec git
They all sux to visualize difference EXCEPT:
1) murphy
2) torte
:colorscheme murphy
Peut etre utile pour cc à la souris dans un split vim ou screen!
Aussi pour cc plusieurs lignes dans vim sans prendre la column number :)
Pour changer de buffer, je faisais :
:ls (pour récupérer la liste des buffers et trouver le numéro du buffer)
:b5 (pour switcher sur le buffer 5)
Pas trop pratique, du coup une alternative sympa :
Put the following in your vimrc:
set wildchar= wildmenu wildmode=full
Ensuite il suffit de faire :
:b
Pour avoir la liste des buffers et itérer dessus avec tab jusqu'à être sur le bon puis
en mode insert : ^V et le code ascii
exemple :ctrl V 003
[Summary, full note in Shaarli]
Habit breaking, habit making (Vimcasts, Feb 6, 2013).
J'utilisais jusqu'à présent aucun plugin vim.. mais l'ouverture de fichier et le switch entre les différents buffers est pénible quand on passe beaucoup de temps dans Vim..
Du coup je teste ctrlP qui est plutot bien une fois configuré !
J'utilise pathogen pour gérer mes plugins, donc dans l'ordre :
- il faut installer pathogen
- ensuite installer ctrlp
Dans le vimrc :
"" CtrlP
map :CtrlPBuffer
map :CtrlP
on a ctrl+B pour naviguer entre les buffers et ctrl+P pour lancer une recherche et ouvrir un fichier
La root de la recherche peut être modifié (par défaut c'est le dossier du fichier ouvert en cours)
On peut lui dire par exemple de remonter jusqu'au .git ou au .svn
Dans mon cas, encore en svn 1.6, il y a un .svn à tous les niveaux... la solution, définir un root marker dans son vimrc :
let g:ctrlp_root_markers = ['.ctrlp']
et ensuite créer ce marker là ou on veut que la recherche se base
$ touch .ctrlp