my ~/.vim/ftplugin/yaml.vim
" put yamllint or any yamlparser in your $PATH
" personnaly, i have
" yamllint () { perl -MYAML -e 'print Dump YAML::LoadFile("'"$1"'")' }
" in my .zshenv
" type ,c in normal mode to know if you file is valid
nnoremap ,c :!yamllint %<cr>
" the common mistakes are
"
" forget a space after the : at the end of a key
" /:\S
" replace : by ; at the end of a key
" /^[^:]+;\s
" forget the comma when you write [ key, { a: a } ]
" /\v\[^,]+\{
"
" put it all together:
" now you can type ,E in normal mode to walk through
" the common mistakes you wrote
nnoremap ,E /\v:\S<bar>\[[^,]+\{<bar>^[^:]+;\s<cr>
I was waiting a long time to have a perl completion system in vim. I waited because i’m lazy and because i thought someone more skilled than me will finally handle that. I don’t know about PPI or other perl parsing technics and i expected the completion to be really smart.
Time passed and there is no such thing in the place. I used ctags completion but it’s very borring to see packages names of your whole @INC when you try to complete a method name.
Still waiting for something really smart, i spent 2 evenings to write a ‘not so smart completion’ … my first use cases surprised me is it seems to be smart enought to go on waiting for another long time
.
I’ll try a daily use starting tomorrow and will feedback in a week. If you can’t wait for testing, debugging, feedback:
the perlcfu git repo
- i wrote some commands that gives me a list of rpm archives i can install on my system.
- i piped the result to vim –
- now i want to search on the list, install some of those packages and keep track on what i installed.
first: split the screen:
now you get:
- the installed at top
- the candidates at bottom
then write a macro:
:nnoremap ,i dd<c-w>kp:!yum install <c-r><c-a><cr>
now, you just have to put the cursor on a candidate and type ,i to install and keep track. yes it works: i’m using it right now
the macro means:
:nnoremap ,i # when you type ,i in normal mode
dd # delete the line
<c-w>k # jump to the top window
p # paste the line
:!yum install # begin to write a shell command: yum install
<c-r><c-a> # append the current line to the command
# :h c_ctrl-r_ctrl-a for futher information
<cr> # validate the shell command by typing <cr> [ENTER]
those kind of things is why i don’t ever consider using another editor.
As rsyncd, the rsync daemon, only supports encryption for authentication, and not for the file-transfer itself, it might be a good idea to switch to rsync over ssh, especially when rsync-ing over the Internet.
But there’s a drawback : you cannot enable server-side logging directly from the server, as you would do with the rsyncd daemon.
Here’s a workaround for enabling server-side logging from the rsync client :
rsync -av --rsync-path="rsync --log-file=/tmp/rsync.log" -e ssh user@host:/remote_dir local_dir
Edit :
Turns out that there is a way to enable server-side logging from the server, even if it does not seem to be well-documented. You can create an rsyncd.conf file in the home directory of the user used for ssh. Here’s the one I use :
id file = /home/user/var/run/rsyncd.pid
log file = /home/user/log/rsync.log
lock file = /home/user/var/run/rsync.lock
uid = user
gid = user
use chroot = no
max connections = 4
transfer logging = true
[export_name]
comment = export_name
path = /mnt/disk/dir
read only = yes
list = no
hosts allow = ip_address
You can then rsync this way :
rsync -av -e ssh user@host::export_name .
tips of this post are cool even if you don’t deal with iso2709.
i wrote a post to explain how sweet it can be to use vim to deal with stdout. Now i want to see the content of a iso2709 file.
as the record separator of iso2709 is « \x1d » but vim
- can’t define a separator different from the standard ones ( combining « \r » and « \n » )
- is very bad to manage very long lines (what an iso2709 file actually is for it)
to navigate in your file, it would be cool to append a « \n » just after « \1xe » (field separator) but with no side effect on the original file. Perl do it easily by mixing -E -0 and -n.
-e flag is to execute perl code ( -E to include perl 5.10 features )
-n make this code executed for each lines of a read file ( $_ : line content, $. : line number )
cat /etc/hosts
# can be written
perl -nEprint /etc/hosts
grep -n localhost /etc/hosts
# can be written
perl -nE '/localhost/ and print "$. : $_"' /etc/hosts
-0 can change the record separator so
perl -0x1e -nEsay biblio.iso2709
read the file field by field ( -0×1xe ) and append a « \n » (say does it) at the end of each one. Pipe it to vi and you’ll have a fast way to walk through your file.
perl -0x1e -nEsay biblio.iso2709 | vim -
also, set dy (display) to uhex to see the hex codes of the separators ( « \x1d » for the record, « \x1e » for field, « \x1f » for subfield)
also note that perl -n accepts some sed style range
# just see the records 10 to 23
perl -0x1d -nE' 10..23 and print' biblio.iso2709 | vim -
# just see from record 10 to the record that contains the word 'plan9'
perl -0x1d -nE' 10../plan9/ and print' biblio.iso2709 | vim -
and the awk style BEGIN and END blocks
# count the number of records
perl -0x1d -nE 'END { say $. }' biblio.iso2709
tappez « apropos git » pour voir la grosse documentation git présente sur votre systeme
( gittutorial gittutorial-2 gitglossary …). il existe une commande git help qui affiche les mans des sous commandes. ainsi, pour avoir la doc de merge, tappez git help merge.
les hooks c’est bien mangez-en.
backupez vos gits avec git-packobjets?
Chris avait posté une astuce pour virer les objets inutiles d’un depot. quelqu’un se souvient ou ?
les guides:
pro git
sourcemage git guide
git magic
hebergements:
heberger soi-même avec gitosis (package debian existant) ou faire un depot publique avec gitorious ou github.
Non classé
tappez « apropos git » pour voir la grosse documentation git présente sur votre systeme
( gittutorial gittutorial-2 gitglossary …). il existe une commande git help qui affiche les mans des sous commandes. ainsi, pour avoir la doc de merge, tappez git help merge.
les hooks c’est bien mangez-en.
backupez vos gits avec git-packobjets?
Chris avait posté une astuce pour virer les objets inutiles d’un depot. quelqu’un se souvient ou ?
les guides:
pro git
sourcemage git guide
git magic
hebergements:
heberger soi-même avec gitosis (package debian existant) ou faire un depot publique avec gitorious ou github.
Non classé
Comment savoir à quelle branche distante correspond telle branche locale ?
donnera :
Remote branch merged with 'git pull' while on branch branche_distante
branche_locale
Non classé
i just edited an sql dump to remove the noise left by a double utf8 encoding using vim. when you are in command line and type ctrl+f, you enter in a history buffer (so you can edit your commands with vi behaviors). I copied the history in my .zshrc and have a simple filter to do it again simply, now.
# act as filter, remove the double encoding
rollback_double_encode () {
perl -Mutf8 -CSD -pe '
s/é/é/g;
s/è/è/g;
s/ê/ê/g;
s/î/Î/g;
s/ô/ô/g;
s/ç/ç/g;
s/ï/ï/g;
s/ë/ë/g;
s/Ã /à/g;
' "$@"
}
well … i imagine it’s not complete but i don’t know a better solution. any idea ?