fix file name and code block syntax

This commit is contained in:
Amolith 2021-03-22 02:55:30 -04:00
parent 4c87de6cb6
commit 366a9f4f66
Signed by: Amolith
GPG Key ID: 5548AD9930655715
9 changed files with 41 additions and 34 deletions

View File

@ -49,6 +49,7 @@ The basic HTML above is exactly the same as what Kev's article has. The CSS is w
cursor: pointer; cursor: pointer;
} }
``` ```
The `position`, `bottom`, and `right` lines are what tell your browser to render the item in the bottom right. The position is `fixed` so that means we can put it wherever on the page we want and it will stay there as the user scrolls. `right` and `bottom` say that the element is to be positioned 10 pixels above the bottom of the page and 10 pixels from the right. It's rather hidden on desktop but I'm not expecting desktop users to click it very often; that's what the `Home` key is for, after all, and it works across every website. I'm expecting mobile users to make use of it the most. The `position`, `bottom`, and `right` lines are what tell your browser to render the item in the bottom right. The position is `fixed` so that means we can put it wherever on the page we want and it will stay there as the user scrolls. `right` and `bottom` say that the element is to be positioned 10 pixels above the bottom of the page and 10 pixels from the right. It's rather hidden on desktop but I'm not expecting desktop users to click it very often; that's what the `Home` key is for, after all, and it works across every website. I'm expecting mobile users to make use of it the most.
--- ---

View File

@ -15,7 +15,7 @@ tags:
I recently started using [calcurse](https://github.com/lfos/calcurse) for my calendar and one of its limitations is good notification support in the generally accepted meaning of the word. The developer has [a different opinion](https://github.com/lfos/calcurse/issues/285#issuecomment-620841221) and that's perfectly alright but traditional notifications are a feature I heavily rely on and calcurse doesn't handle handle them very well; it leaves the user to figure something out on their own. Inspired by [one individual's issue](https://github.com/lfos/calcurse/issues/286#issue-608118188), I did just that. I recently started using [calcurse](https://github.com/lfos/calcurse) for my calendar and one of its limitations is good notification support in the generally accepted meaning of the word. The developer has [a different opinion](https://github.com/lfos/calcurse/issues/285#issuecomment-620841221) and that's perfectly alright but traditional notifications are a feature I heavily rely on and calcurse doesn't handle handle them very well; it leaves the user to figure something out on their own. Inspired by [one individual's issue](https://github.com/lfos/calcurse/issues/286#issue-608118188), I did just that.
A quick glance at `man calcurse` reveals this section: A quick glance at `man calcurse` reveals this section:
``` ```text
-n, --next -n, --next
Print the first appointment within the next 24 hours. The Print the first appointment within the next 24 hours. The
printed time is the number of hours and minutes left before printed time is the number of hours and minutes left before
@ -23,7 +23,7 @@ A quick glance at `man calcurse` reveals this section:
``` ```
The output of running `calcurse -n`, for me and at the moment, looks like this: The output of running `calcurse -n`, for me and at the moment, looks like this:
``` ```text
calcurse -n calcurse -n
next appointment: next appointment:
[17:25] DnD on Mumble [17:25] DnD on Mumble
@ -43,17 +43,17 @@ Now we're actually getting somewhere. With my setup, the notification looks like
![It's a screenshot of my desktop with a notification in the top right corner. The title is "Calcurse Event" and the text below is "DnD on Mumble". Surrounding the text is a solid border. Its position and the border are all that designate it as a notification: the background and text colour match the rest of my desktop which is themed with the base16-unikitty-dark scheme](/assets/jpgs/notification.jpg) ![It's a screenshot of my desktop with a notification in the top right corner. The title is "Calcurse Event" and the text below is "DnD on Mumble". Surrounding the text is a solid border. Its position and the border are all that designate it as a notification: the background and text colour match the rest of my desktop which is themed with the base16-unikitty-dark scheme](/assets/jpgs/notification.jpg)
It's certainly passable and sufficient for some but I'd like an icon so I can see what the notification is for out of the corner of my eye and decide whether or not to glance over. Thankfully, `notify-send` has this built in with the `-i` flag. It's certainly passable and sufficient for some but I'd like an icon so I can see what the notification is for out of the corner of my eye and decide whether or not to glance over. Thankfully, `notify-send` has this built in with the `-i` flag.
``` ```text
-i, --icon=ICON[,ICON...] -i, --icon=ICON[,ICON...]
Specifies an icon filename or stock icon to display. Specifies an icon filename or stock icon to display.
``` ```
Now it's just a matter of figuring out what icon to use. You can certainly pass the path of whatever image you want to it, such as `~/Pictures/calendar-icon.png`, but I want something that fits in with the rest of my icons. These are found in: Now it's just a matter of figuring out what icon to use. You can certainly pass the path of whatever image you want to it, such as `~/Pictures/calendar-icon.png`, but I want something that fits in with the rest of my icons. These are found in:
``` ```bash
/usr/share/icons/<theme>/it/depends/on/theme /usr/share/icons/<theme>/it/depends/on/theme
``` ```
I use [Suru++ Dark](https://github.com/gusbemacbe/suru-plus-dark) and the icon I'm using can be found at: I use [Suru++ Dark](https://github.com/gusbemacbe/suru-plus-dark) and the icon I'm using can be found at:
``` ```bash
/usr/share/icons/Suru++-Dark/apps/32@2x/calendar.svg /usr/share/icons/Suru++-Dark/apps/32@2x/calendar.svg
``` ```
It's different for Adwaita and all the rest though; you'll have to do some digging. It's also worth noting that, if you don't have this theme installed on another device, the icon won't show up. It's different for Adwaita and all the rest though; you'll have to do some digging. It's also worth noting that, if you don't have this theme installed on another device, the icon won't show up.

View File

@ -29,7 +29,7 @@ RTMP stands for [Real-Time Messaging Protocol](https://wikipedia.org/wiki/Real-T
On Debian-based systems, adding RTMP functionality to NGINX is as simple as `apt install libnginx-mod-rtmp`. After that, you'll need to add some things to your `nginx.conf` and whatever host file you're using for your website. On Debian-based systems, adding RTMP functionality to NGINX is as simple as `apt install libnginx-mod-rtmp`. After that, you'll need to add some things to your `nginx.conf` and whatever host file you're using for your website.
```conf ```c
rtmp { rtmp {
server { server {
listen 1935; listen 1935;
@ -50,13 +50,13 @@ rtmp {
``` ```
`1935` is the default RTMP port. `deny publish all` means you are denying *anyone* from publishing a stream (that includes you. `allow publish 127.0.0.1` allows *local* connections to publish content. I'm using this as a form of authentication---before streaming anything, I have to tunnel my connection to my server via SSH or a VPN. At the moment, I'm using SSH: `1935` is the default RTMP port. `deny publish all` means you are denying *anyone* from publishing a stream (that includes you. `allow publish 127.0.0.1` allows *local* connections to publish content. I'm using this as a form of authentication---before streaming anything, I have to tunnel my connection to my server via SSH or a VPN. At the moment, I'm using SSH:
``` ```text
ssh -L 1935:localhost:1935 user@example.com ssh -L 1935:localhost:1935 user@example.com
``` ```
The other options are just the basics needed to get DASH and HLS to work. The only other thing to do is use NGINX as a reverse proxy (sort of) to serve the streams. Add this to your site's virtual host. The other options are just the basics needed to get DASH and HLS to work. The only other thing to do is use NGINX as a reverse proxy (sort of) to serve the streams. Add this to your site's virtual host.
``` ```c
location /dash { location /dash {
root /tmp; root /tmp;
} }
@ -67,12 +67,12 @@ location /hls {
That's it! Now you'll need to test your stream and verify that it actually works. That's it! Now you'll need to test your stream and verify that it actually works.
``` ```bash
ffmpeg -re -i video.mp4 -vcodec copy -loop -1 -c:a aac -b:a 160k -ar 44100 -strict -2 -f flv rtmp://example.com/live/stream ffmpeg -re -i video.mp4 -vcodec copy -loop -1 -c:a aac -b:a 160k -ar 44100 -strict -2 -f flv rtmp://example.com/live/stream
``` ```
This command has FFmpeg play the video and stream it to the server. You should then be able to open the stream in something like [VLC](https://www.videolan.org/) or [MPV](https://mpv.io/) and watch it from anywhere. This command has FFmpeg play the video and stream it to the server. You should then be able to open the stream in something like [VLC](https://www.videolan.org/) or [MPV](https://mpv.io/) and watch it from anywhere.
``` ```bash
mpv https://example.com/dash/stream.mpd mpv https://example.com/dash/stream.mpd
``` ```
@ -102,7 +102,7 @@ Finally, I landed on [qwebirc](https://qwebirc.org/) and it was pretty much *exa
**EDIT:** Since the time of writing, I have switched to hosting [KiwiIRC](https://kiwiirc.com/) on [Secluded.Site](https://chat.secluded.site) so all of the trackers and third parties aren't in use. My configs are below but I recommend going through [the wiki](https://github.com/kiwiirc/kiwiirc/wiki/Configuration-Options) and making your own decisions. **EDIT:** Since the time of writing, I have switched to hosting [KiwiIRC](https://kiwiirc.com/) on [Secluded.Site](https://chat.secluded.site) so all of the trackers and third parties aren't in use. My configs are below but I recommend going through [the wiki](https://github.com/kiwiirc/kiwiirc/wiki/Configuration-Options) and making your own decisions.
`/etc/kiwiirc/config.conf` `/etc/kiwiirc/config.conf`
``` ```ini
logLevel = 3 logLevel = 3
identd = false identd = false
gateway_name = "webircgateway" gateway_name = "webircgateway"

View File

@ -20,7 +20,7 @@ After [downloading](https://www.mediawiki.org/wiki/Download) and [installing](ht
## URLs ## URLs
The first thing in `LocalSettings.php` is `$wgScriptPath`. Different wikis take vastly different approaches for this. Some fill that variable with `"/w"` (default), some with `"/view"`, and some with something entirely different. [Wikipedia](https://wikipedia.org/wiki/MediaWiki) and all of its children use `"/wiki"`. While well and good, the default configuration will have your URLs appearing as `example.com/wiki/index.php?title=<page>` and this is bad practise for SEO; if you want your pages easily discoverable, the URLs need to be a bit shorter. The easiest way I've found to do this is add all of six lines to my NGINX config and set `$wgScriptPath` to `""` (an empty string). The first thing in `LocalSettings.php` is `$wgScriptPath`. Different wikis take vastly different approaches for this. Some fill that variable with `"/w"` (default), some with `"/view"`, and some with something entirely different. [Wikipedia](https://wikipedia.org/wiki/MediaWiki) and all of its children use `"/wiki"`. While well and good, the default configuration will have your URLs appearing as `example.com/wiki/index.php?title=<page>` and this is bad practise for SEO; if you want your pages easily discoverable, the URLs need to be a bit shorter. The easiest way I've found to do this is add all of six lines to my NGINX config and set `$wgScriptPath` to `""` (an empty string).
``` ```text
location / { location / {
try_files $uri $uri/ @rewrite; try_files $uri $uri/ @rewrite;
} }
@ -28,6 +28,7 @@ location @rewrite {
rewrite ^/(.*)$ /index.php?title=$1&$args; rewrite ^/(.*)$ /index.php?title=$1&$args;
} }
``` ```
The snippet above tells NGINX to rewrite all of your site's base URLs and remove `index.php?title=` from them. This is a similar approach to what [Mozilla](https://wiki.mozilla.org/Main_Page) has done. The result is cleaner URLs that comply with SEO best practises and a setup that avoids [moving MediaWiki to the site's root](https://www.mediawiki.org/wiki/Manual:Wiki_in_site_root_directory). The snippet above tells NGINX to rewrite all of your site's base URLs and remove `index.php?title=` from them. This is a similar approach to what [Mozilla](https://wiki.mozilla.org/Main_Page) has done. The result is cleaner URLs that comply with SEO best practises and a setup that avoids [moving MediaWiki to the site's root](https://www.mediawiki.org/wiki/Manual:Wiki_in_site_root_directory).
## Mobile view ## Mobile view
@ -42,6 +43,7 @@ wfLoadExtension( 'MobileFrontend' );
$wgMFDefaultSkinClass = 'SkinMinerva'; $wgMFDefaultSkinClass = 'SkinMinerva';
$wgMFAutodetectMobileView = true; $wgMFAutodetectMobileView = true;
``` ```
With the skin and extension in place and those lines in your config, save and reload and there should be a link at the bottom of your wiki called `Mobile view`. Click it and you'll see Minerva! On a phone, MobileFrontend will automatically serve it but you can force your default theme by clicking `Desktop view` in the same location. With the skin and extension in place and those lines in your config, save and reload and there should be a link at the bottom of your wiki called `Mobile view`. Click it and you'll see Minerva! On a phone, MobileFrontend will automatically serve it but you can force your default theme by clicking `Desktop view` in the same location.
![Screenshot of the mobile versions of my MediaWiki instance. The left uses Minerva Neue and the right uses Vector. The left has buttons and icons that are much larger and easier to tap making for better accessibility. Though the text is readable, the touch targets are much too small navigation is hell](/assets/pngs/mediawiki-skins.png) ![Screenshot of the mobile versions of my MediaWiki instance. The left uses Minerva Neue and the right uses Vector. The left has buttons and icons that are much larger and easier to tap making for better accessibility. Though the text is readable, the touch targets are much too small navigation is hell](/assets/pngs/mediawiki-skins.png)
@ -59,8 +61,9 @@ As I said, the left works but most people wouldn't know what to do when given th
wfLoadExtension( 'Echo' ); wfLoadExtension( 'Echo' );
wfLoadExtension( 'Flow' ); wfLoadExtension( 'Flow' );
``` ```
Running the following commands is necessary because MediaWiki's database needs modification to support the extension. General talk pages are `--ns=1` and `User:Talk` pages are `--ns=3`. If you only want Structured Discussions enabled for one of them, only run that one. I personally recommend doing it for all. Running the following commands is necessary because MediaWiki's database needs modification to support the extension. General talk pages are `--ns=1` and `User:Talk` pages are `--ns=3`. If you only want Structured Discussions enabled for one of them, only run that one. I personally recommend doing it for all.
``` ```text
php maintenance/populateContentModel.php --wiki=somewiki --ns=1 --table=revision php maintenance/populateContentModel.php --wiki=somewiki --ns=1 --table=revision
php maintenance/populateContentModel.php --wiki=somewiki --ns=1 --table=archive php maintenance/populateContentModel.php --wiki=somewiki --ns=1 --table=archive
php maintenance/populateContentModel.php --wiki=somewiki --ns=1 --table=page php maintenance/populateContentModel.php --wiki=somewiki --ns=1 --table=page
@ -69,6 +72,7 @@ php maintenance/populateContentModel.php --wiki=somewiki --ns=3 --table=revision
php maintenance/populateContentModel.php --wiki=somewiki --ns=3 --table=archive php maintenance/populateContentModel.php --wiki=somewiki --ns=3 --table=archive
php maintenance/populateContentModel.php --wiki=somewiki --ns=3 --table=page php maintenance/populateContentModel.php --wiki=somewiki --ns=3 --table=page
``` ```
After that, add these to actually enable the extension. To temporarily disable it, you can comment them out but I don't know how that will affect talk pages that already exist. After that, add these to actually enable the extension. To temporarily disable it, you can comment them out but I don't know how that will affect talk pages that already exist.
```php ```php
# Flow (discussions) configuration # Flow (discussions) configuration
@ -91,6 +95,7 @@ wfLoadExtension( 'CodeMirror' );
# Enables it by default but allows users to disable it # Enables it by default but allows users to disable it
$wgDefaultUserOptions['usecodemirror'] = 1; $wgDefaultUserOptions['usecodemirror'] = 1;
``` ```
![screenshot of the mediawiki editor. headers are larger, code blocks are highlighted, links blue with link text black so it's easy to pick out, etc. In all, it's a much nicer experience.](/assets/pngs/mediawiki-highlight.png) ![screenshot of the mediawiki editor. headers are larger, code blocks are highlighted, links blue with link text black so it's easy to pick out, etc. In all, it's a much nicer experience.](/assets/pngs/mediawiki-highlight.png)
## Editing in Vim ## Editing in Vim

View File

@ -19,8 +19,9 @@ We all love the CLI *(and if we don't, we should)* so wouldn't it be great if th
+ Weather for today - `$ curl sky.webionite.com/f/location/t` + Weather for today - `$ curl sky.webionite.com/f/location/t`
A great way to make this faster and simpler is to put an alias in your shell's `rc` file. For bash, you can do that with: A great way to make this faster and simpler is to put an alias in your shell's `rc` file. For bash, you can do that with:
``` ```bash
echo "alias weather='curl sky.webionite.com/f/location'" >> ~/.bashrc echo "alias weather='curl sky.webionite.com/f/location'" >> ~/.bashrc
``` ```
If you ever forget how to use the tool, just run `curl sky.webionite.com` and you'll be given instructions. If you ever forget how to use the tool, just run `curl sky.webionite.com` and you'll be given instructions.
![screenshot of the output of the command. it shows two rows of four boxes with ascii art depicting rain, overcast clouds, and the sun obscured by clouds. it shows the temperature and the time of day. everything is coloured and looks very attractive.](/assets/pngs/weather.png) ![screenshot of the output of the command. it shows two rows of four boxes with ascii art depicting rain, overcast clouds, and the sun obscured by clouds. it shows the temperature and the time of day. everything is coloured and looks very attractive.](/assets/pngs/weather.png)

View File

@ -13,13 +13,13 @@ tags:
--- ---
I've been trying off and on for the past few weeks to figure out how to record my 1920x1080 monitor. The recording is going to be some music videos for a friend. Originally, it was just going to be a single background image for the whole video then I had the idea of using [cava](https://github.com/karlstav/cava) in a transparent terminal on top of the background. This didn't work at all because it actually kept freezing when I tried to record it. So I tried switching to [ncmpcpp](http://ncmpcpp.rybczak.net/)'s visualiser. This still had horrible lag so I've been puzzling over how to use ffmpeg to *losslessly* record my second monitor. The reason OBS and similar screen recorders are so slow is because, most of the time, they encode to the end format while recording and that uses a lot of system resources. I finally figured it out and have pasted the command below. I've been trying off and on for the past few weeks to figure out how to record my 1920x1080 monitor. The recording is going to be some music videos for a friend. Originally, it was just going to be a single background image for the whole video then I had the idea of using [cava](https://github.com/karlstav/cava) in a transparent terminal on top of the background. This didn't work at all because it actually kept freezing when I tried to record it. So I tried switching to [ncmpcpp](http://ncmpcpp.rybczak.net/)'s visualiser. This still had horrible lag so I've been puzzling over how to use ffmpeg to *losslessly* record my second monitor. The reason OBS and similar screen recorders are so slow is because, most of the time, they encode to the end format while recording and that uses a lot of system resources. I finally figured it out and have pasted the command below.
``` ```bash
ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -draw_mouse 0 -i :0.0+1366,0 -c:v libx264 -crf 0 -preset ultrafast output.mkv ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -draw_mouse 0 -i :0.0+1366,0 -c:v libx264 -crf 0 -preset ultrafast output.mkv
``` ```
Above is exactly what I used for my 1080p monitor with 768p laptop screen. I've modified the command so you can see what you need to edit for your use-case. Above is exactly what I used for my 1080p monitor with 768p laptop screen. I've modified the command so you can see what you need to edit for your use-case.
``` ```bash
ffmpeg -video_size <target-resolution> -framerate 30 -f x11grab -i :0.0+<width-of-unused-monitor>,0 -c:v libx264 -crf 0 -preset ultrafast <filename>.mkv ffmpeg -video_size <target-resolution> -framerate 30 -f x11grab -i :0.0+<width-of-unused-monitor>,0 -c:v libx264 -crf 0 -preset ultrafast <filename>.mkv
``` ```
@ -27,11 +27,11 @@ If you do *not* want the cursor recorded, add `-draw_mouse 0` directly after `x1
My video was 470mb for a ~13 minute video. If you're going to archive the recording or are concerned about file size, re-encode it with a slower preset. This will be a lot slower and take a lot of CPU but the resulting file is *significantly* smaller than the original and still lossless. I this as a general purpose screen recorder. Previously, I was using OBS and the lag in the video was incredible but with ffmpeg, it's smooth as butter. The command for re-encoding is below: My video was 470mb for a ~13 minute video. If you're going to archive the recording or are concerned about file size, re-encode it with a slower preset. This will be a lot slower and take a lot of CPU but the resulting file is *significantly* smaller than the original and still lossless. I this as a general purpose screen recorder. Previously, I was using OBS and the lag in the video was incredible but with ffmpeg, it's smooth as butter. The command for re-encoding is below:
``` ```bash
ffmpeg -i output.mkv -c:v libx264 -crf 0 -preset veryslow output-smaller.mkv ffmpeg -i output.mkv -c:v libx264 -crf 0 -preset veryslow output-smaller.mkv
``` ```
![](/assets/gifs/ffmpeg-lossless.gif) ![](/assets/gifs/ffmpeg-lossless.gif)
# Note ## Note
This command only works with X, not Wayland. Skimming `ffmpeg`'s man page, I see that `video4linux2` is another option for capturing video so you may be able to replace `x11grab` with it for the same result. I have not tested this so I don't know if it'll work or not. This command only works with X, not Wayland. Skimming `ffmpeg`'s man page, I see that `video4linux2` is another option for capturing video so you may be able to replace `x11grab` with it for the same result. I have not tested this so I don't know if it'll work or not.

View File

@ -182,7 +182,7 @@ dl linustechtips https://www.youtube.com/user/LinusTechTips
``` ```
The result would be this directory structure: The result would be this directory structure:
``` ```text
YouTube YouTube
├── .archives ├── .archives
│   └── linustechtips.txt │   └── linustechtips.txt

View File

@ -22,7 +22,7 @@ I'm not exactly sure why but dead keys don't have to be held down when you want
Dead keys allow writers to use far more characters that just the accented ones found in various alphabets. Indeed, one can type a *very* wide variety of symbols: Dead keys allow writers to use far more characters that just the accented ones found in various alphabets. Indeed, one can type a *very* wide variety of symbols:
``` ```text
™ © ® § ¶ ∵ € ¢ ¥ ⅞ x³ ∞ ¬ ÷ ± × ≠ ♪ ♬ ♭ ♮ ♯ → ⇒ ☭ ㉔ ⓐ ß æ ø Œ ™ © ® § ¶ ∵ € ¢ ¥ ⅞ x³ ∞ ¬ ÷ ± × ≠ ♪ ♬ ♭ ♮ ♯ → ⇒ ☭ ㉔ ⓐ ß æ ø Œ
``` ```
@ -39,17 +39,17 @@ How you enable dead keys or the compose key depends *entirely* on your operating
Depending on whether you want dead keys or a compose key, there are different commands to run. I'm not sure how to enable the former—you'll need to read [the page for that](https://wiki.archlinux.org/index.php/Xorg/Keyboard_configuration) yourself—but mapping an existing key to compose is really easy. Depending on whether you want dead keys or a compose key, there are different commands to run. I'm not sure how to enable the former—you'll need to read [the page for that](https://wiki.archlinux.org/index.php/Xorg/Keyboard_configuration) yourself—but mapping an existing key to compose is really easy.
List what your options are List what your options are
``` ```text
grep "compose:" /usr/share/X11/xkb/rules/base.lst grep "compose:" /usr/share/X11/xkb/rules/base.lst
``` ```
Copy which first column you want and paste it into this command Copy which first column you want and paste it into this command
``` ```text
setxkbmap -option <option-goes-here> setxkbmap -option <option-goes-here>
``` ```
I mapped mine to the right `Alt` key as I never use it and it's near the space bar. The command for that would simply be: I mapped mine to the right `Alt` key as I never use it and it's near the space bar. The command for that would simply be:
``` ```text
setxkbmap -option compose:ralt setxkbmap -option compose:ralt
``` ```
@ -57,7 +57,7 @@ For other interesting things you can do with your keyboard, check [that whole se
## Edit ## Edit
Since the time of publication, I've started using [Wayland](https://wayland.freedesktop.org/) and configuring your keyboard with `setxkbmap` doesn't work. Instead, assuming you're running [sway](https://github.com/swaywm/sway/), add something along this vein to your config. If you want to use something other than your right `Alt` key, make sure you change that. Since the time of publication, I've started using [Wayland](https://wayland.freedesktop.org/) and configuring your keyboard with `setxkbmap` doesn't work. Instead, assuming you're running [sway](https://github.com/swaywm/sway/), add something along this vein to your config. If you want to use something other than your right `Alt` key, make sure you change that.
``` ```text
input type:keyboard xkb_options compose:ralt input type:keyboard xkb_options compose:ralt
``` ```

View File

@ -17,20 +17,20 @@ I've recently decided to attempt to keep all of my notes and everything I've lea
Because it's all in a simple text file, I'm also able to create a keybinding in [Sway](https://github.com/swaywm/sway/) that will open it in Vim, jump to the bottom, and have a nice markdown environment ready for me to write in. It did take a bit of configuration and looking around for different plugins but I'm very happy with what I have so far. Because it's all in a simple text file, I'm also able to create a keybinding in [Sway](https://github.com/swaywm/sway/) that will open it in Vim, jump to the bottom, and have a nice markdown environment ready for me to write in. It did take a bit of configuration and looking around for different plugins but I'm very happy with what I have so far.
The first thing is telling Vim to treat all `.md` files as Markdown The first thing is telling Vim to treat all `.md` files as Markdown
``` ```vim
" Treat all .md files as markdown " Treat all .md files as markdown
autocmd BufNewFile,BufRead *.md set filetype=markdown autocmd BufNewFile,BufRead *.md set filetype=markdown
``` ```
## Visuals ## Visuals
In a long text file with a great many lines, it can be useful to find your cursor quickly without having to search around the screen for it. In a long text file with a great many lines, it can be useful to find your cursor quickly without having to search around the screen for it.
``` ```vim
" Highlight the line the cursor is on " Highlight the line the cursor is on
autocmd FileType markdown set cursorline autocmd FileType markdown set cursorline
``` ```
It can also be nice to not see a ton of \[links](https\://example.com) and \*\*bold** or \*italic* text everywhere. Sure, my eye has gotten used to it but still. I'd rather have my terminal actually render bold text as bold. It can also be nice to not see a ton of \[links](https\://example.com) and \*\*bold** or \*italic* text everywhere. Sure, my eye has gotten used to it but still. I'd rather have my terminal actually render bold text as bold.
``` ```vim
" Hide and format markdown elements like **bold** " Hide and format markdown elements like **bold**
autocmd FileType markdown set conceallevel=2 autocmd FileType markdown set conceallevel=2
``` ```
@ -38,7 +38,7 @@ If you use the `vim-markdown` plugin mentioned further on, I recommend using its
## Spell check ## Spell check
One of the things every good editor needs is spell check and Vim is no exception. This line enables spell check with British English for all markdown files. One of the things every good editor needs is spell check and Vim is no exception. This line enables spell check with British English for all markdown files.
``` ```vim
" Set spell check to British English " Set spell check to British English
autocmd FileType markdown setlocal spell spelllang=en_gb autocmd FileType markdown setlocal spell spelllang=en_gb
``` ```
@ -52,18 +52,18 @@ Here's a short crash course in Vim spelling commands:
## Goyo ## Goyo
The very first component is something I use across *all* markdown files. [Goyo](https://github.com/junegunn/goyo.vim) is one of the first plugins I install on any machine I'll be writing with. It enables a "distraction-free writing environment" and I absolutely love it. It disables pretty much all visual elements in Vim except for what mode you're in: visual, command, insert, etc. I have a keybinding set to quickly open/close Goyo because there is an odd issue when I switch workspaces to and away from Vim. With two taps of `Ctrl+g`, it's back to normal. The very first component is something I use across *all* markdown files. [Goyo](https://github.com/junegunn/goyo.vim) is one of the first plugins I install on any machine I'll be writing with. It enables a "distraction-free writing environment" and I absolutely love it. It disables pretty much all visual elements in Vim except for what mode you're in: visual, command, insert, etc. I have a keybinding set to quickly open/close Goyo because there is an odd issue when I switch workspaces to and away from Vim. With two taps of `Ctrl+g`, it's back to normal.
``` ```vim
nnoremap <C-g> :Goyo<CR> nnoremap <C-g> :Goyo<CR>
``` ```
Another line in my Vim config automatically opens Goyo for all markdown files: Another line in my Vim config automatically opens Goyo for all markdown files:
``` ```vim
autocmd FileType markdown Goyo autocmd FileType markdown Goyo
``` ```
## vim-markdown ## vim-markdown
That latest plugin I installed is [vim-markdown](https://github.com/plasticboy/vim-markdown) and it is *wonderful*. I really recommend reading about all of the options but here's what I have set. That latest plugin I installed is [vim-markdown](https://github.com/plasticboy/vim-markdown) and it is *wonderful*. I really recommend reading about all of the options but here's what I have set.
``` ```vim
" Configuration for vim-markdown " Configuration for vim-markdown
let g:vim_markdown_conceal = 2 let g:vim_markdown_conceal = 2
let g:vim_markdown_conceal_code_blocks = 0 let g:vim_markdown_conceal_code_blocks = 0
@ -80,7 +80,7 @@ In addition to the rest of the awesome features, the main one I wanted is the la
## General Vim things ## General Vim things
Other, more general Vim settings that I use globally but might also be nice for editing markdown Other, more general Vim settings that I use globally but might also be nice for editing markdown
``` ```vim
" Have lines wrap instead of continue off-screen " Have lines wrap instead of continue off-screen
set linebreak set linebreak
@ -111,14 +111,14 @@ In all, I'm hoping that the work I've done today for improving my markdown workf
## Edit ## Edit
### Time stamps ### Time stamps
``` ```vim
" Insert timestamp at the end of the line in this format: 20200527T113245 " Insert timestamp at the end of the line in this format: 20200527T113245
nnoremap <C-t><C-s> m'A<C-R>=strftime('%Y%m%dT%H%M%S')<CR> nnoremap <C-t><C-s> m'A<C-R>=strftime('%Y%m%dT%H%M%S')<CR>
``` ```
### Portable `autocmd`s ### Portable `autocmd`s
Put all the `autocmd` lines in the `if` statement so they don't throw errors when the config is added to a version of vim without `autocmd` support Put all the `autocmd` lines in the `if` statement so they don't throw errors when the config is added to a version of vim without `autocmd` support
``` ```vim
" Only enable autocommands when Vim supports them " Only enable autocommands when Vim supports them
if has("autocmd") if has("autocmd")
"" ""