2021-10-28 16:32:16 +02:00
2021-10-26 11:36:07 +02:00
2021-10-23 16:36:39 +02:00
2021-10-29 09:05:15 +02:00

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.

USER="marvin" ./set_header.sh

If you want to setup the same email and username for all your git:

git config --global user.name marvin
git config --global user.email marvin@student.42lausanne.ch

Otherwise setup it on a case-by-case basic:

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

For non git-based folder, set user and mail values directly in your vimrc

vim ~/.vimrc
let g:user42 = 'marvin'
let g:mail42 = 'marvin@student.42lausanne.ch'

ESC :wq

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

If you want to setup the same email and username for all your git:

git config --global user.name marvin
git config --global user.email marvin@student.42lausanne.ch

Otherwise setup it on a case-by-case basic:

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.) edit ~/.zshrc:

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

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

vim ~/.bashrc
export MAIL="marvin@student.42lausanne.ch"
<ESC> :wq
source ~/.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.
  • Usually you don't want to overwrite $USER as is the logged user and is already defined.

Troubleshooting:

git config user.name
echo $USER
git config user.email
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

Bonus

test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin
git clone https://github.com/xbeheydt/42-vim-headerguard.git 42-vim-headerguard
cd 42-vim-headerguard
cp -va plugin/* ~/.vim/plugin/
  • Swissair is gone? Have a look to Airline for a nice status for vim.
test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin
test -d ~/.vim/autoload || mkdir -p ~/.vim/autoload
git clone https://github.com/vim-airline/vim-airline.git vim-airline
cd vim-airline
cp -va autoload/* ~/.vim/autoload/
cp -va plugin/* ~/.vim/plugin/

RTFM

License

This work is published under the terms of 42 Unlicense.

Description
42 standard header for vim editor.
Readme 2.2 MiB
Languages
Vim script 89.3%
Shell 10.7%