Files
42header/README.md
2021-10-28 16:44:32 +02:00

2.4 KiB

42 Header

42Lausanne (Switzerland)

Description

42 standard header for vim editor.

42 header

Usage

In NORMAL mode (ESC) you can simply press the shortcut F2 (or FN F2) or use :FT as command.

vim 42.c
<ESC> <F2>
<ESC> :wq

vim Makefile
<ESC> :FT
<ESC> :wq

Quick Setup

Below replace "marvin" with your 42 Network login.

export USER="marvin"
export MAIL="marvin@student.42lausanne.ch"

./set_header.sh

In all your git repositories:

git clone git@... project
cd project
git config user.name "marvin"
git config user.email "marvin@student.42lausanne.ch"

Manual Setup

Below replace "marvin" with your 42 Network login.

Copy stdheader.vim in your ~/.vim/plugin.

test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin
cp -va vim/stdheader.vim ~/.vim/plugin

In all your git repositories:

git clone git@... project
cd project
git config user.name "marvin"
git config user.email "marvin@student.42lausanne.ch"

UNIX/BSD Distro (MacOS X, FreeBSD, OpenBSD, etc.) Add in ~/.zshrc your:

vim ~/.zshrc
export USER="marvin"
export MAIL="marvin@student.42lausanne.ch"
<ESC> :wq
source ~/.zshrc

Linux/GNU Distro (Debian/Ubuntu, RedHat/SuSE, Arch, Gentoo, etc.) Add in ~/.bashrc your:

vim ~/.bashrc
export USER="marvin"
export MAIL="marvin@student.42lausanne.ch"
<ESC> :wq
. ~/.bashrc

Note

  • Your git username and email will always have the priority over $USER and $MAIL variables.
  • if you are outside a git repo tree, it will use the $USER and $MAIL environement variables.
  • if none of the above, it will default to marvin@student.42lausanne.ch and marvin as username.

Troubleshooting:

git config user.name
git config user.email
echo $USER
echo $MAIL
grep -e 'USER=' -e 'MAIL=' ~/.zshrc

The location of this alternative version of stdheader.vim:

  • ~/.vim/plugin/stdheader.vim
  • $HOME/.vim/plugin/stdheader.vim

The location of the official stdheader.vim in 42lausanne's clusters:

  • /usr/share/vim/vim80/plugin/stdheader.vim
  • /usr/share/vim/vim81/plugin/stdheader.vim (at the time of writing)
  • /usr/share/vim/vim82/plugin/stdheader.vim

Credits

License

This work is published under the terms of 42 Unlicense.